Regain Lost Root MySQL Access Permissions When Connecting From Localhost

To reset the root access from localhost for a MySQL instance, enter the following commands in a terminal with root/su privilages.


# /etc/init.d/mysqld stop

# mysqld_safe --skip-grant-tables &

# mysql -u root

mysql> use mysql;

mysql> CREATE USER 'root'@'localhost' IDENTIFIED BY 'yourpassword';

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'


mysql> flush privileges;

mysql> quit


You should now be able to log in as root on the local machine using the ‘yourpassword’ that you entered.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s