SystemMen - This article will show you how to create read-only user in MySQL.
In which case do you need to use user read-only in MySQL? Normally in monitor systems, at the dashboard, you only need to use a read-only user.
This user will read data from the database and display information to the dashboards.
Commands to create a read-only user
You execute the following commands to create a user with SELECT
permission in MySQL.
First, use the following command to create youruser
user with the ip login is localhost
.
CREATE USER 'youruser'@'localhost' IDENTIFIED BY 'yourpassword';
Next, use the following command to create youruser
user with the ip login as your remote ip. For example, the remote ip is 192.168.100.10
.
CREATE USER 'youruser'@'192.168.100.10' IDENTIFIED BY 'yourpassword';
Next, use the following command to grant SELECT
permission (equivalent to read-only) to the user who just created your database.
Recommended Reading: How to install MariaDB 10.3 in Debian 8
GRANT SELECT ON yourdatabase . * TO 'youruser'@'localhost'; GRANT SELECT ON yourdatabase . * TO 'youruser'@'192.168.100.10';
And finally, you use the flush command in mysql to apply a new user.
FLUSH PRIVILEGES;
Conclusion
So you’ve created the read-only user in MySQL. The commands are quite simple but sometimes you won’t remember how to do it. Even I myself.
Hope it will be useful for you at some time.
«« Fix OpenVPN route gateway is not reachableThe df command shows the disk is full but it is not »»