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:
- Firstly, log in to the MariaDB server as a user with administrative privileges.
- 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';
- 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';
- 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.