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'

-> WITH GRANT OPTION;

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.

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s