Under Linux systems, MySQL database is a very common and important data management tool. When using MySQL, we usually need to set relevant permissions to achieve better data security management. The following are some commonly used MySQL permission setting methods.
Before setting the MySQL permissions, we first need to create a new user. You can use the following command to create a user named "newuser" with the password "password":
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
The user "newuser" here can only be used locally. If remote access is required, you need to change "localhost" Change to remote IP address.
After the user is created, we need to grant the corresponding permissions. The following are some commonly used authorization commands:
GRANT ALL PRIVILEGES ON exampledb.* TO 'newuser'@'%';
GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost';
GRANT SELECT,INSERT ON exampledb.* TO 'newuser'@'localhost';
If you need to revoke the permissions of a user, you can use the following command:
REVOKE ALL PRIVILEGES ON exampledb.* FROM 'newuser'@'%';
REVOKE ALL PRIVILEGES ON *.* FROM 'newuser'@'localhost';
REVOKE SELECT,INSERT ON exampledb.* FROM 'newuser'@'localhost';
When setting MySQL permissions, you also need to pay attention to the following points:
In summary, MySQL permission settings are very important and are also part of database security management. Basic permission settings can be made through the above commands, but in specific use, they need to be flexibly adjusted according to the actual situation.
The above is the detailed content of How to set mysql permissions in linux. For more information, please follow other related articles on the PHP Chinese website!