Create a Database and Assign a User
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.
[View All Snippets]
[View All Snippets]
Show Plain Text »
- -- 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';