Search code examples
mysqldatabasemariadbprivileges

grant create database privilege to mariadb user


I know that in database management, it's a bad behavior to use the root user and I'm setting up a custom user with base privileges (create database, drop db, all access to all newly created dbs, etc).
I've created a user antoine which should be the base user used to login to the mariadb server.

Problem is, I can't figure out how to grant administration privileges like create database xxx, drop database xxx, etc... The documentation explains that to grant a privilege, you run the following command:

GRANT role ON database.table TO user@host

But, when it comes to server privileges, how can I do it ? I've tried the *.* instead of database.table but it's not working.


Solution

  • Create a user and then grant that user the privileges you want them to have like this.

    CREATE USER 'antoine'@'localhost' IDENTIFIED VIA mysql_native_password USING 'a-password';
    GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON *.* TO 'antoine'@'localhost';