1

[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                                  |
+-------------------------------------------------------------------------------------------------------------+

3 Answers 3

1

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.
1
  • Did this answer solve your problem ??? Commented Jul 20, 2020 at 20:13
0

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.

3
  • Permissions were assigned by the administrator days ago, no need to flush
    – anthony
    Commented Sep 26, 2019 at 12:33
  • @anthony Does you want to say that server reboots during this days? If no - flush, it is safe.
    – Akina
    Commented Sep 26, 2019 at 12:48
  • i did it. it doesn't work.
    – anthony
    Commented Sep 26, 2019 at 12:51
0

If your user is granted USAGE it won't help much. You need the privilege CREATE DATABASE to be allowed to create databases. The documentation says you can grant the privilege even for nonexisting databases.

See https://mariadb.com/kb/en/grant/#database-privileges

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.