How to create a user and grant permissions in MariaDB?

To create a user and grant permissions in MariaDB, you can follow the steps below:

  1. Firstly, log in to the MariaDB server as a user with administrative privileges.
  2. Create a new user using the following command (for example, with the username “new_user” and the password “user_password”):
CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'user_password';
  1. Grant new users appropriate permissions. For example, if you want to grant a new user full access to a specific database, you can use the following command:
GRANT ALL PRIVILEGES ON database_name.* TO 'new_user'@'localhost';

If you only want to grant specific permissions, you can use the following command:

GRANT SELECT, INSERT, UPDATE ON database_name.* TO 'new_user'@'localhost';
  1. Finally, refresh the permissions for the changes to take effect.
FLUSH PRIVILEGES;

By following the steps above, you have successfully created a new user and granted appropriate permissions in MariaDB.

Leave a Reply 0

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


广告
Closing in 10 seconds
bannerAds