Create a MySQL user and set privileges to the user in one command

  • First: login as root:

# mysql -p -u root

  • Second: create a new database:

CREATE DATABASE dbname;

  • This command creates the user “dbuser” with the password “dbuserPassword” and assign all privileges to the database “dbname”

GRANT ALL ON dbname.* TO [email protected] IDENTIFIED BY 'dbuserPassword';

 

Tags:

Add a Comment

Your email address will not be published. Required fields are marked *