MySQL to add new users can be done in two ways:
1. By way of the grant statement, we will explain this in the MySQL permissions below, which is simply an example.
2. Direct operation of the MySQL authorization form (this method is now basically not used)
Description: The more common approach is to use the GRANT statement to complete the increase of new users
Basic format:
Grant permission name on database. * To User name @ login host identified by "password"
1. Create Account
The code is as follows |
Copy Code |
CREATE USER ' Jeffrey ' @ ' localhost ' identified by ' I pass ';
|
2, delete the account (delete the account will also delete all its permissions)
The code is as follows |
Copy Code |
DROP USER ' Jeffrey ' @ ' localhost ';
|
3. Assigning Permissions
The code is as follows |
Copy Code |
Grant all privileges on *.* to ' Jeffrey ' @ '% ' identified by ' password ' with GRANT OPTION
|
4, Recycling permissions
The code is as follows |
Copy Code |
REVOKE INSERT on *.* from ' Jeffrey ' @ ' localhost '; REVOKE all privileges, GRANT OPTION from ' Jeffrey ' @ ' localhost ';
|
5, the account name change
The code is as follows |
Copy Code |
RENAME USER ' Jeffrey ' @ ' localhost ' to ' Jeff ' @ ' 127.0.0.1 ';
|
6, modify the password
The code is as follows |
Copy Code |
SET PASSWORD = PASSWORD (' Mypass '); SET PASSWORD for ' Jeffrey ' @ ' localhost ' = PASSWORD (' Mypass '); |
How does MySQL view all of the added user information?
Basic format:
The code is as follows |
Copy Code |
SELECT * from Mysql.user; |
For example:
The code is as follows |
Copy Code |
Mysql>select Host,user,password from Mysql.user; Car |
Attention
MySQL user name is up to 16 characters in length. This limits the hard coding between the MySQL server and the client and prevents the password from being stolen by modifying the definition of the table in the MySQL database.
Note: You should never modify any of the tables in the MySQL database in any way, only the scripts provided for this purpose are run by the MySQL distribution secondary school. Redefining the MySQL system tables as otherwise would result in undefined (and unsupported!) Behavior.
The operating system username is completely unrelated to the MySQL username, or even the maximum length may be different. For example, the UNIX user name is limited to 8 characters