--Authorize a user (Zhangsan) password 123, you can do all the operations on all the libraries, all the tables.
Mysql> Grant All on * * to [e-mail protected] '% ' identified by ' 123 ';
Query OK, 0 rows affected (0.17 sec)
-The refresh takes effect, otherwise it is necessary to restart the MySQL service.
mysql> flush Privileges;
Query OK, 0 rows Affected (0.00 sec)
--Browse current MySQL user information
Mysql> select User,host,password from Mysql.user;
+----------+-----------------+-------------------------------------------+
| user | Host | password |
+----------+-----------------+-------------------------------------------+
| Root | localhost | *23ae809ddacaf96af0fd78ed04b6a265e05aa257 |
| Root | 127.0.0.1 | |
| | localhost | |
| Zhangsan | % | *23ae809ddacaf96af0fd78ed04b6a265e05aa257 |
| admin | 192.168.112.132 | *23ae809ddacaf96af0fd78ed04b6a265e05aa257 |
+----------+-----------------+-------------------------------------------+
5 rows in Set (0.00 sec)
--Remove some permissions
--Revoke: Only user permissions were removed, but the user was not deleted
Mysql> Revoke Insert,delete on * * FROM [e-mail protected] identified by ' 123 ';
--View permission information for a specified user
Mysql> Show grants for [email protected];
+------------------------------------------------------------------------------------------------------------+
| Grants for [email protected] |
+------------------------------------------------------------------------------------------------------------+
| GRANT USAGE on *. xbb ' @ ' localhost ' identified by PASSWORD ' *23ae809ddacaf96af0fd78ed04b6a265e05aa257 ' |
+------------------------------------------------------------------------------------------------------------+
--drop User: Deletes the entire users and their permissions (including data in the data dictionary)
mysql> drop user ' xbb ' @ ' localhost ';
Query OK, 0 rows Affected (0.00 sec)
Mysql> select User,host from Mysql.user;
+------------------+-----------+
| user | Host |
+------------------+-----------+
| Root | 127.0.0.1 |
| Debian-sys-maint | localhost |
| Root | localhost |
| Root | Wangxg |
+------------------+-----------+
4 rows in Set (0.00 sec)
User Rights Management for MySQL server