Grant is typically used to create users and authorizations
Syntax format
GRANT
Priv_type [(column_list)]
[, Priv_type [(column_list)] ...
On [object_type] Priv_level
To User_specification [, user_specification] ...
[REQUIRE {NONE | ssl_option [[and] ssl_option] ...}]
[With {GRANT OPTION | resource_option} ...]
Grant all on test.* to "TestUser1" @ "127.0.0.1" identified by "test";
Underline the place to explain
The location of all is a command that can be used, or it can be a select,update,delete, separated by commas when used;
The location of the test.* is the table of which library, which represents all the tables in the test database;
"TestUser1" @ "127.0.0.1" is the specified user and IP from
"Test" is the password for test
Any of the above is preceded by a preposition, memory may be a bit difficult, to practice more.
In addition, this command creates a user first and then authorizes the corresponding.
If the combination of the user and IP already exists, the password is changed, and if it does not exist, a new combination is created (in the MySQL database user table)
mysql> select user,password,host from mysql.user;+-----------+------------------------- ------------------+-------------+| user | password | host |+-----------+-------------------------------------------+-------------+| root | *1981B3D87F8E4997E444AC2F469A74D5145EEB7X | localhost | | root | | vmtest.js | | root | *1981B3D87F8E4997E444AC2F469A74D5145EEB7X | 127.0.0.1 | | root | | ::1 | | | | localhost | | | & nbsp; | vmtest.js | | root | *1981B3D87F8E4997E444AC2F469A74D5145EEB7X | 192.168.5.% | | coosh | *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC2X | 127.0.0.1 | | testuser1 | *94bdcebe19083ce2a1f959fd02f964c7af4cfc2x | 127.0.0.1 | +-----------+-------------------------------------------+-------------+9 rows in set (0.00  SEC) mysql> grant select,update on test.* to "Coosh" @ "192.168.5.%" identified by "XXX"; query ok, 0 rows affected (0.00 sec) mysql> select user,password,host from mysql.user; +-----------+------------------------- ------------------+-------------+| user | password | host |+-----------+-------------------------------------------+-------------+| root | *1981B3D87F8E4997E444AC2F469A74D5145EEB7X | localhost | | root | | vmtest.js | | root | *1981B3D87F8E4997E444AC2F469A74D5145EEB7X | 127.0.0.1 | | root | | ::1 | | | | localhost | | | | vmtest.js | | root | *1981B3D87F8E4997E444AC2F469A74D5145EEB7X | 192.168.5.% | | coosh | *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC2X | 127.0.0.1 | | testuser1 | *94bdcebe19083ce2a1f959fd02f964c7af4cfc2x | 127.0.0.1 | | coosh | *91A66B6C7D4FABDB9225374DC006BB98E6C6F0CX | 192.168.5.% |+-----------+-------------------------------------------+-------------+10 rows in set (0.00 sec)
Linux Learning Notes: Creating Users and authorizations