Grant all privileges of a database to a MySQL user?

MySQLMySQLi Database

First, create a user and password using CREATE command. The syntax is as follows.

CREATE USER 'yourUserName'@'localhost' IDENTIFIED BY 'yourPassword';

The syntax to give all privileges of the specific database to the user is as follows.

GRANT ALL PRIVILEGES ON yourDatabaseName . * TO 'yourUserName'@'localhost';

Now you can implement the above syntaxes to create a user and grant all privileges. The query is as follows to create a user.

mysql> create user 'Adam Smith'@'localhost' IDENTIFIED BY 'Adam123456';
Query OK, 0 rows affected (0.29 sec)

Now, grant all privileges to the user. The query is as follows.

mysql> GRANT ALL PRIVILEGES ON test . * TO 'Adam Smith'@'localhost';
Query OK, 0 rows affected (0.19 sec)
Published on 11-Jan-2019 16:35:19