Last active
April 25, 2024 15:09
-
-
Save cnicodeme/7767509 to your computer and use it in GitHub Desktop.
Create a new Mysql user with restricted access
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
# Difference unicode/general : http://stackoverflow.com/a/367725/330867 | |
CREATE DATABASE dbname CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | |
CREATE USER 'dbuser'@'localhost' IDENTIFIED BY 'dbpass'; | |
GRANT USAGE ON * . * TO 'dbuser'@'localhost' IDENTIFIED BY 'dbpass' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ; | |
GRANT SELECT , INSERT , UPDATE , DELETE , CREATE , DROP , INDEX , ALTER , REFERENCES, LOCK TABLES ON `dbname` . * TO 'dbuser'@'localhost'; | |
FLUSH PRIVILEGES; | |
# To dump the database with the master relay details: | |
# mysqldump database --master-data=1 > db.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment