Last active
December 30, 2015 03:49
-
-
Save kevinruscoe/09f5edfe1fb6a3d1bef4 to your computer and use it in GitHub Desktop.
How to create a MySQL user and assign it to a databases.
This file contains 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
# ~1~ = Datbase Name | |
# ~2~ = New MySQL username | |
# ~3~ = The new users password | |
# Create a database | |
CREATE DATABASE `~1~`; | |
# Create a user | |
CREATE USER '~2~'@'localhost' IDENTIFIED BY '~3~'; | |
# Assign it the new database | |
GRANT ALL PRIVILEGES ON `~1~`.* TO '~2~'@'localhost'; | |
# Reload privilegs | |
FLUSH PRIVILEGES; | |
# SAMPLE | |
CREATE DATABASE `DB_NAME`; | |
CREATE USER 'DB_USERNAME'@'localhost' IDENTIFIED BY 'DB_PASSWORD'; | |
GRANT ALL PRIVILEGES ON `DB_NAME`.* TO 'DB_USERNAME'@'localhost'; | |
FLUSH PRIVILEGES; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment