1

now, I can login the mysql with mysql -uroot -p, then I input my password.

Then I try to do this.

mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | +--------------------+

But when I create database, i get an error:

mysql> CREATE DATABASE newdb; ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'newdb'

this is my grants:

mysql> show grants; +------------------------------------------+ | Grants for root@localhost | +------------------------------------------+ | GRANT USAGE ON *.* TO 'root'@'localhost' | +------------------------------------------+

on the terminal with MacOSX. Thanks for any help.

idsbllp
  • 836
  • 9
  • 8
  • This question is repeated http://stackoverflow.com/questions/21714869/error-1044-42000-access-denied-for-root-with-all-privileges – juanitourquiza Jan 14 '17 at 15:48

1 Answers1

1

From the docs, GRANT USAGE is a:

Synonym for “no privileges”

Leaving aside the point that this privilege has a confusing name, I'm not sure how/why you have such limited privileges for root, anyway.

What you want for root is GRANT ALL. Even better, leave root as-is and create a different superuser with local-only access to replace root. But do note that, in general, you want to give users only the bare minimum privileges necessary for whatever they need to do.

elixenide
  • 44,308
  • 16
  • 74
  • 100
  • Hw to create superuser without having any permission at all. I have tried to create a user but that also shows access denied for root user. Can you please guide me how to do that – jayaprakash R May 04 '22 at 16:48
  • @jayaprakashR For obvious reasons, you can't create a user (much less a superuser) if you don't have permissions. It would completely defeat the point of having permissions if you could do that. – elixenide May 10 '22 at 04:05