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.
- -- 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';
You need to login to post a comment.