Saturday, December 3, 2016

Reset MySQL root password


Following is a way to reset MySQL root password when you forgot.
  1. Stop MySQL: /etc/init.d/mysqld stop
  2. Startup MySQL without password prompt: mysqld_safe --skip-grant-tables &
  3. Login to MySQL: mysql --user=root mysql
  4. Reset password: mysql> update user set Password=PASSWORD('new-password') where user='root';
  5. mysql> flush privileges;
  6. mysql> exit;
  7. Kill running mysql daemon: kill mysql-pid
  8. Start MySQL: /etc/init.d/mysqld start

No comments: