One. Create user command:
' username '@'host'password';
Description
- Username: The user name you will create
- Host: Specifies on which host the user can log on, if localhost is available to the local user, if you want the user to be able to log in from any remote host , you can use a wildcard character
%
- Password: The user's login password, password can be empty, if it is empty, the user can not need password login server
Example:
CREATE USER'Dog'@'localhost'Identified by'123456'; CREATE USER'Pig'@'192.168.1.101_'Idendified by'123456'; CREATE USER'Pig'@'%'Identified by'123456'; CREATE USER'Pig'@'%'Identified by"'; CREATE USER'Pig'@'%';
Two. Authorization: command:
' username '@'host'
Description
- Privileges: User's operation permissions, such as,,
SELECT
INSERT
UPDATE
etc., if the permission to be granted is usedALL
- DatabaseName: Database name
- TableName: Table name, if you want to grant the user the appropriate operation permissions on all databases and tables
*
, the representation is available, such as*.*
Example:
' Pig '@'%'pig'@'% '; GRANT all on Maindataplus. ' Pig '@'%';
Attention:
A user authorized with the above command cannot authorize another user, and if you want the user to be authorized to do so, use the following command:
' username '@'host' with GRANT OPTION;
Three. Set and change user password commands:
' username '@'host' = PASSWORD ('newpassword');
If the current user is logged in with:
SET PASSWORD = PASSWORD ("newpassword");
Example:
' Pig '@'%' = PASSWORD ("123456");
Four. Revoke User Rights command:
' username '@'host';
Description
Privilege, DatabaseName, TableName: With the authorization section
Example:
' Pig '@'%';
Attention:
If you ‘pig‘@‘%‘
are doing this (or the like) when authorizing a user, the use of a GRANT SELECT ON test.user TO ‘pig‘@‘%‘
command does REVOKE SELECT ON *.* FROM ‘pig‘@‘%‘;
not revoke the user's action on the users table in the test database SELECT
. Conversely, if authorization is used, GRANT SELECT ON *.* TO ‘pig‘@‘%‘;
the REVOKE SELECT ON test.user FROM ‘pig‘@‘%‘;
command cannot revoke the user's permissions to the users table in the test database Select
.
Specific information can be viewed with commands SHOW GRANTS FOR ‘pig‘@‘%‘;
.
Five. Delete User command:
' username '@'host';
MySQL Create user and authorization