Last active
January 2, 2019 20:26
-
-
Save alejandrofloresm/a886b7b83d07475e69d8a54df425c6cb to your computer and use it in GitHub Desktop.
Generate and grant new permissions to a MySQL user to a new database
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. Create the database | |
* Change: | |
* <database_name>: to your database name | |
*/ | |
CREATE DATABASE <database_name>; | |
/** | |
* 2. Create the user | |
* Change: | |
* <username> to your username | |
* <server:localhost> | |
* <your_password> to your password | |
*/ | |
CREATE USER '<username>'@'<server:localhost>' IDENTIFIED BY 'your_password'; | |
/** | |
* 3. Set the priviliges and finally flush the priviliges | |
* Change: | |
* <username> to your username | |
* <server:localhost> | |
* The ...ON '<database_name>'.* TO... the * is for all the tables | |
*/ | |
GRANT ALL PRIVILEGES ON <database_name>.* TO '<username>'@'<server:localhost>'; | |
FLUSH PRIVILEGES; | |
/** | |
* No comments section | |
*/ | |
CREATE DATABASE <database_name>; | |
CREATE USER '<username>'@'<server:localhost>' IDENTIFIED BY 'your_password'; | |
GRANT ALL PRIVILEGES ON <database_name>.* TO '<username>'@'<server:localhost>'; | |
FLUSH PRIVILEGES; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment