Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nightlyworker/94e0fdf1148e0a04f9230f123cd0f4a5 to your computer and use it in GitHub Desktop.
Save nightlyworker/94e0fdf1148e0a04f9230f123cd0f4a5 to your computer and use it in GitHub Desktop.
Create a MySQL database and create a user with all grant on it
CREATE USER 'DB_USERNAME'@'localhost' IDENTIFIED BY 'DB_PASSWORD';
GRANT USAGE ON * . * TO 'DB_USERNAME'@'localhost' IDENTIFIED BY 'DB_PASSWORD' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
CREATE DATABASE IF NOT EXISTS `DB_USERNAME` ;
GRANT ALL PRIVILEGES ON `DB_USERNAME` . * TO 'DB_USERNAME'@'localhost';
#For connection from everywhere
GRANT USAGE ON * . * TO 'DB_USERNAME'@'%' IDENTIFIED BY 'DB_PASSWORD' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0
GRANT ALL PRIVILEGES ON `DB_USERNAME` . * TO 'DB_USERNAME'@'%';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment