Skip to content

Instantly share code, notes, and snippets.

@dehamzah
Last active June 30, 2020 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dehamzah/174310190c91b357d8e933fa2bb61e1b to your computer and use it in GitHub Desktop.
Save dehamzah/174310190c91b357d8e933fa2bb61e1b to your computer and use it in GitHub Desktop.
Create read only mysql database user
# 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