#After completing the mysql installation for the first time, you should set a password for the root user of mysql
#Log in to mysql
mysql –u root and press Enter
Set password=PASSWORD('111111'); //Set the root password to 111111
#First time use , check the user table of mysql. For security reasons, we will delete non-root users and users who are not allowed to log in from the local
Show databases;
Use mysql;
Select user,host,password from user;
Delete from user where user != 'root'; //Delete all non-root users from the permission table
Delete from user where host !='localhost'; //Delete users who log in from any host other than localhost
#Create a local administrator account (i.e. for All libraries can perform any operation, but can only log in locally)
Grant all privileges on *.* to account name@localhost identified by “password” with grant option;
#Create a user who only has permissions for a certain library , Generally, in our actual production environment, applications accessing the database server are all on the same LAN, and we can create users like this.
Grant all on database name.* to account name@'192.168.1.%' identified by "password";
#Create a slave user, you will need to use it when doing master-slave synchronization in the future
Grant replication slave on *.* to Account name@"from IP" identified by 'password';
#View the permissions of a user
Show grants; //View your own permissions
Show grants for user@'host' //View the permissions of this user, here The user and host must be consistent with the mysql.user table.
These are the most commonly used ones. After adding all permissions, you must enter flush privileges; before they will take effect.
The above is the MYSQL learning summary (3): MYSQL generates user and empowerment content. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!