Created
February 2, 2014 09:34
-
-
Save apphp/8765344 to your computer and use it in GitHub Desktop.
Create a Database and Assign a User
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
/* | |
This is a very simple snippet about how to create a database 1st, | |
a user and then assign some privileges to the user to allow him/her to | |
perform some specific actions like insert, create, update, select etc. | |
Source: http://www.apphp.com/index.php?snippet=mysql-create-database-and-assign-user | |
*/ | |
-- Create database, user and grant all privileges | |
CREATE DATABASE database_name; | |
CREATE USER 'user_name'@'localhost' IDENTIFIED BY 'password'; | |
GRANT ALL PRIVILEGES ON database_name.* TO 'user_name'@'localhost'; | |
-- To grant just specific privileges, use the following format: | |
GRANT SHOW DATABASES, SELECT, UPDATE, LOCK TABLES, RELOAD ON *.* TO 'user_name'@'localhost'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment