First, the landing database
Mysql-u root-p [super User password];
Second, create a new user
CREATE USER ' username ' @ ' host ' identified by ' password ';
Parameter description:
1, Username: You will create the user name;
2, Host: Specify the user on which host can log on, if the local user is available localhost;
If you want the user to be able to log on from any remote host , you can use the wildcard character%;
3、Password: The user's login password, password can be empty, if it is empty, the user can not require a password to log on to the server.
Third, to the user authorization
Grant privileges on Databasename.tablename to ' username ' @ ' host ';
Parameter description:
1, privileges: User's operation rights, such as,, SELECT INSERT UPDATE etc., if you want to grant the permission to useALL;
2, DatabaseName: database name;
3, TableName: Table name, if you want to grant the user the appropriate operation permissions on all databases and tables can be * represented, such as*.*。
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:
GRANT privileges on Databasename.tablename to ' username ' @ ' host ' with GRANT OPTION;
Iv. Refreshing permission information
Flush privileges;
V. Restart the database
Service MySQL Restart
Vi. Connecting the database
mysql-h [Server address]-p [port number]-u [user name]-p [user password]
Vii. Supplementary Parts
1. Revoke Permissions
REVOKE privilege on Databasename.tablename from ' username ' @ ' host ';
2. Setting and changing user passwords
SET PASSWORD for ' username ' @ ' host ' = PASSWORD (' NewPassword ');
If the current user is logged in: SET PASSWORD = PASSWORD ("NewPassword");
3. Delete users
DROP USER ' username ' @ ' host ';
Regular users connect to MySQL database from other hosts