Tuesday, 28 February 2012

MYSQL - Reset root password [Unix Systems]

1. Stop the MYSQL Service

Code Snippet
  1. service mysqld stop
End of Code Snippet

or

Code Snippet
  1. /etc/init.d/mysqld stop
End of Code Snippet


2. Execute the following SQL (Replace 'rootpass' woith password first)

Code Snippet
  1. mysqld_safe --skip-grant-tables &
  2. mysql -uroot mysql
  3. UPDATE user SET password=PASSWORD("rootpass") WHERE user="root";
  4. FLUSH PRIVILEGES;
End of Code Snippet


3. Start the MYSQL Service

Code Snippet
  1. service mysqld start
End of Code Snippet

or

Code Snippet
  1. /etc/init.d/mysqld start
End of Code Snippet



Windows Users

I imagine by typing in 'services.msc' into Start > Run, you can stop the MYSQL service there, follow the steps above, then restart the service.

No comments: