Reset MySQL root password – Linux

1. Stop the MySQL service as root.

# /etc/init.d/mysql stop
or
#service mysql stop

2. Start MySQL in safe mode and skip “grant tables”:
# /usr/bin/mysqld_safe –user=mysql –socket=/var/lib/mysql/mysql.sock –pid-file=/var/run/mysqld/mysqld.pid –datadir=/var/lib/mysql –skip-grant-tables –skip-networking &
3. Now, reset the MySQL root password using mysqladmin
# mysqladmin -u root flush-privileges password new_password_here
4. Stop MySQL running in safe mode:
#kill `cat /var/run/mysqld/mysqld.pid`
5. Start MySQL:
#/etc/init.d/mysql start
6. You can use the new MySQL root password now :
#mysql -u root -p
When prompted for the new password, enter the new password you have set using mysqladmin

Advertisements

Tags:

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


%d bloggers like this: