Can’t create database even with all privileges

Posted on

Question :

[mariaDB on RedHat 7.7]

I just want to create a new database, but found “access denied”:

create database lamp_k;

ERROR 1044 (42000): Access denied for user ‘lamp’@’localhost’ to database ‘lamp_k’

These are my privileges:

+-------------------------------------------------------------------------------------------------------------+
| Grants for lamp@localhost                                                                                   |
+-------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'lamp'@'localhost' IDENTIFIED BY PASSWORD '*F90C7030DCB590F7C8E0ED955DA6222DE699A9E8' |
| GRANT ALL PRIVILEGES ON `lamp_*`.* TO 'lamp'@'localhost' WITH GRANT OPTION                                  |
+-------------------------------------------------------------------------------------------------------------+

Answer :

Your problem is very simple.

  • You have grants to do things in any existing database that starts with lamp_.
  • You do not have permission to create a new database even if it starts with lamp_.
  • You would need at least GRANT CREATE ON *.* to create databases.

Before the changes actually take action, you need to run

FLUSH PRIVILEGES

EDIT:
Just saw that you tried to grant Privileges on a database which doesn’t exists. You need to give them global privileges to create databases.

Leave a Reply

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