Last active
June 30, 2020 15:39
-
-
Save dehamzah/174310190c91b357d8e933fa2bb61e1b to your computer and use it in GitHub Desktop.
Create read only mysql database user
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Login | |
$ mysql -u root -p | |
# Check privileges | |
$ SHOW GRANTS FOR 'read-only_user_name'@'%'; | |
# Remove the privileges if any | |
$ REVOKE ALL PRIVILEGES ON database_name.* FROM 'read-only_user_name'@'%'; | |
# Give the user access to the database from any host | |
$ GRANT SELECT ON database_name.* TO 'read-only_user_name'@'%' IDENTIFIED BY 'password'; | |
# Update privileges | |
$ FLUSH PRIVILEGES; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment