查询用户名
>mysql use mysql;
Database changed
>mysql select user,host from user
+———+———————–+
| user | host |
+———+———————–+
| root | [127.0.0.1] |
| | localhost |
| root | localhost |
| | localhost.localdomain |
| root | localhost.localdomain |
+———+———————–+
7 rows in set (0.00 sec)
mysql> show grants for root@’localhost’;
+——————————————————+
| Grants for root@localhost |
+——————————————————+
| GRANT ALL PRIVILEGES ON *.* TO ‘root’@'localhost’ WITH GRANT OPTION |
+——————————————————+
1 row in set (0.00 sec)
mysql>
mysql> select db,user ,host from db;
+———+——+————–+
| db | user | host |
+———+——+————–+
| test | | % |
| test\_% | | % |
| db | test | 172.20.1.124 |
+———+——+————–+
3 rows in set (0.00 sec)
mysql>
Grant 用法
mysql> GRANT <privileges> ON <what>
-> TO <user> [IDENTIFIED BY "<password>"]
-> [WITH GRANT OPTION];
例如:GRANT USAGE ON . TO ‘discuz’@'localhost’ IDENTIFIED BY PASSWORD ’123456′;</pre>
网友评论