Reset mysql database root password

  1. stop mysql server
  2. $ /etc/init.d/mysql stop

    if it doesn’t work then kill the process

    $ ps aux | grep mysql

    now you got the mysql pid, then kill it

    $ kill -9 <pid>

  3. run mysql server safe mode with option –skip-grant-tables
  4. $ /usr/bin/safe_mysqld --skip-grant-tables

  5. login to your mysql server using user root
  6. $ /usr/bin/mysql -u root

  7. change the root password
  8. mysql> UPDATE user SET Password=PASSWORD('YOUR_PASSWORD') WHERE Host='localhost' AND User='root';

  9. restart mysql server
  10. $ /etc/init.d/mysql restart

Advertisement

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 )

Connecting to %s

Follow

Get every new post delivered to your Inbox.