How to create a MySQL user with limited rights?

I would like to create a user called webapp who can access a database called webdb with the following privileges

 Select, Insert, Update, Delete, Create, Drop, References, Index, Alter, Lock_Tables 

I created such a database

 mysql -u root -p -e 'create database webdb' 

How is such a user created from the command line?

+4
source share
1 answer

Something like that:

 CREATE USER 'new_user'@'host_name' IDENTIFIED BY 'password'; GRANT SELECT, INSERT, UPDATE, DELETE, ALTER, CREATE, DROP, INDEX, LOCK TABLES, REFERENCES ON webdb.* TO 'new_user'@'host_name'; 

The second statement will grant privileges to the webdb database.

+7
source

Source: https://habr.com/ru/post/1395196/


All Articles