It is a common operation to create a user and giant all the permission to a specific database.

Step 1: Create a database
MariaDB [(none)]> CREATE DATABASE my_database_name;
Query OK, 1 row affected (0.00 sec)
Step 2: Grant permissions to operate the database for a new user
MariaDB [(none)]> GRANT ALL ON my_database_name.* TO 'my_user_name'@'localhost' IDENTIFIED BY 'my_password';
Query OK, 0 rows affected (0.01 sec)

Note:

  • GRANT "ALL" means this new user can do everything in this database. Please visit this page, update the keyword "all" and using appropriate keywords instead if you wanna to create a restricted user.
  • my_database_name.* means this new user will able to operate all the tables in this database.
  • 'my_user_name'@'localhost' means this user can only visit the page from local. If you wish this new user able to visit from remote, you should use "0.0.0.0" or your host, ip instead of 'localhost'
Step 3: Refresh Privileges
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

This command will reload the privileges, and then you can login using your new user and password

来自的你,很高兴你能看到这儿。若本文对你有所用处,或者内容有什么不足之处,敬请毫不犹豫给个回复。谢谢!