How To Fix MySQL Denied For User Root Localhost

April 3, 2019 • ☕️ 1 min read

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';

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