First, use the CREATE command to create a user and password. The syntax is as follows.
CREATE USER 'yourUserName'@'localhost' IDENTIFIED BY 'yourPassword';
The syntax to grant all permissions to a specific database to a user is as follows.
GRANT ALL PRIVILEGES ON yourDatabaseName . * TO 'yourUserName'@'localhost';
Now you can implement the above syntax to create a user and grant all permissions. The query to create a user is as follows.
mysql> create user 'Adam Smith'@'localhost' IDENTIFIED BY 'Adam123456'; Query OK, 0 rows affected (0.29 sec)
Now, grant all permissions 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)
The above is the detailed content of Grant all permissions to database to MySQL user?. For more information, please follow other related articles on the PHP Chinese website!