Skip to content

Instantly share code, notes, and snippets.

@d1y
Forked from hpatoio/gist:4398399
Created March 15, 2021 02:46
Show Gist options
  • Save d1y/d809eed89a7b957b04c7f7dab15ea258 to your computer and use it in GitHub Desktop.
Save d1y/d809eed89a7b957b04c7f7dab15ea258 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