I would like to create a user called webapp
that can access a database called webdb
with the following privileges
Select, Insert, Update, Delete, Create, Drop, References, Index, Alter, Lock_Tables
I created the database like so
mysql -u root -p -e 'create database webdb'
How is such a user created from the commandline?
To GRANT ALL privileges to a user , allowing that user full control over a specific database , use the following syntax: mysql> GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost';
Something like this:
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';
Second statement will grant privileges on webdb
database.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With