1. 程式人生 > >給mysql的root %使用者新增grant許可權。並給建立的使用者賦予許可權

給mysql的root %使用者新增grant許可權。並給建立的使用者賦予許可權

##登入mysql

[[email protected] bin]# ./mysql -u root -p
mysql> use mysql

##檢視許可權

mysql> select user,host,grant_priv from user;
+---------------+-----------+------------+
| user          | host      | grant_priv |
+---------------+-----------+------------+
| root          | localhost | Y          |
| mysql.session | localhost | N          |
| mysql.sys     | localhost | N          |
| root          | %         | N          |
| zhoufei       | %         | N          |
| lsj           | %         | N          |
+---------------+-----------+------------+
6 rows in set (0.00 sec)

##修改許可權

mysql> update user set grant_priv='Y'
    -> where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 2  Changed: 1  Warnings: 0


mysql> flush privileges
    -> ;
Query OK, 0 rows affected (0.03 sec)

##結果

mysql> select user,host,grant_priv from user;
+---------------+-----------+------------+
| user          | host      | grant_priv |
+---------------+-----------+------------+
| root          | localhost | Y          |
| mysql.session | localhost | N          |
| mysql.sys     | localhost | N          |
| root          | %         | Y          |
| zhoufei       | %         | N          |
| lsj           | %         | N          |
+---------------+-----------+------------+
6 rows in set (0.00 sec)

##現在就能給使用者賦予許可權了