Access Denied For User 'root'@'localhost' (using Password Yes) Mac Os

The default password for user root is blank (i.e. An empty string). If in case it has never been changed then you may simply login to root user using mysql when you try to login to root user using mysql -u root -p, and if you enter wrong password, you may face ERROR 1045 (28000): Access denied for.

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?

Mac

If reinstall, I will lose the database game_data, right? Follow the steps below. • Start the MySQL server instance or daemon with the --skip-grant-tables option (security setting). $ mysqld --skip-grant-tables • Execute these statements.

$ mysql -u root mysql $mysql> UPDATE user SET Password=PASSWORD('my_password') where USER='root'; $mysql> Ntfs for mac free download. FLUSH PRIVILEGES; If you face the unknown field Password error above use: update user set authentication_string=password('my_password') where user='root'; • Finally, restart the instance/daemon without the --skip-grant-tables option. $ /etc/init.d/mysql restart You should now be able to connect with your new password. $ mysql -u root -p Enter password: my_password Fix for MySQL “Unable to lock ibdata1” error sudo mv /usr/local/mysql/data/ibdata1 /usr/local/mysql/data/ibdata1.bak sudo mv /usr/local/mysql/data/ib_logfile0 /usr/local/mysql/data/ib_logfile0.bak sudo mv /usr/local/mysql/data/ib_logfile1 /usr/local/mysql/data/ib_logfile1.bak sudo cp -a /usr/local/mysql/data/ibdata1.bak /usr/local/mysql/data/ibdata1 sudo cp -a /usr/local/mysql/data/ib_logfile0.bak /usr/local/mysql/data/ib_logfile0 sudo cp -a /usr/local/mysql/data/ib_logfile1.bak /usr/local/mysql/data/ib_logfile1 sudo /etc/init.d/mysql restart.

None of the above were helpful for me. I found I needed to clear the plugin method.

In 5.6, I could do: sudo mysql -u root use mysql; [mysql] update user set plugin=' where User='root'; [mysql] flush privileges; In 5.7, I found I needed to: sudo mysql -u root use mysql; [mysql] update user set plugin='mysql_native_password' where User='root'; [mysql] flush privileges; According to the docs, with plugin set to an empty string, it should have effectively defaulted to mysql_native_password, but may be getting confused by an empty password hash. For more nuance, you can read the documentation here.