130
70
Before I screw up something, when I login using $ mysql -u root -p
, and show databases:
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| game_data |
| test |
+--------------------+
Then I tried to create a new user and notice something is wrong with the PRIVILEGES.
So I deleted the new users, and I guess I removed the 'root' and 'Admin' accidentally.
Then I try to create 'root' again, but get Access denied error when doing grant all privileges.
mysql> CREATE USER 'root'@'localhost' IDENTIFIED BY 'password';
mysql> grant all privileges on *.* to 'root'@'localhost' identified by 'password' with grant option;
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
If I login to MySQL again using $ mysql -u root -p
, and show databases,
+--------------------+
| Database |
+--------------------+
| information_schema |
+--------------------+
All the other databases are gone.
How do I fix MySQL now?
I cannot find the database 'mysql', cannot create database, create user, anything I try to do will get an error.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES).
Should I reinstall MySQL using MacPorts? If reinstall, I will lose the database game_data
, right?
Also see How to have MySQL entitle the root user? on Super User. It attempts to avoid resetting passwords.
– jww – 2016-04-02T11:28:14.870I just had a space between
-p
and the password. I know its silly but might help someone. – Vinay Wadhwa – 2017-02-23T07:18:36.923Try accesing the server with 'root'@'127.0.0.1' which is diferent from 'root'@'localhost'. Then issue a command to create the user 'root'@'localhost' and grant all privileges to it. – Gimmy – 2013-06-03T08:06:45.573