This article summarizes and introduces the methods of creating new users and authorization in Mysql. It first introduces the author's own project experience, and then attaches reference articles. I hope it will be helpful to everyone in learning mysql.
During the project development process, you may need to open your own database to others, but for security reasons, you cannot open other databases in your server at the same time. Then you can create a new user and grant specific database permissions to the user.
Test environment: Centos 6.3 and Mysql 5.3
1. Create a new user
The code is as follows:
//Log in to MYSQL
@>mysql -u root -p
@>Password
//Create user
mysql> insert into mysql.user(Host,User,Password) values("localhost","cplusplus",password("cplusplus .me"));
//Refresh the system privileges table
mysql>flush privileges;
This creates a user named: cplusplus with the password: cplusplus.me.
2. Login test
1 2 3 4 |
|
3. User authorization
1 2 3 4 5 6 7 8 9 10 |
|
4. Partial authorization
1 2 3 |
|
5. Delete users
1 2 3 4 |
|
6. Delete database
1 |
|
7. Change password
1 2 3 4 |
|
Let me share with you an experience from a netizen:
1. Create a new user
Log in to mysql as user root and create a new user with the same name as the database.
1 |
|
Refresh system permission table
1 |
|
If an error is reported
1 |
|
Modify the MySQL configuration file to my.cnf for Linux systems and my.ini for Windows systems
1 |
|
change into
1 |
|
Restart the MySQL service
2. Authorize users
1 2 |
|