20090422

reset mysql root password

If you have forgotten the root mysql password and you do not have an alternate user with equivalent permissions you can easily define a new root password following the below steps.

Note: Obviously mysql connections will be interrupted during this processes as we will be restarting the service and not listening on the network for a bit.

  • /etc/init.d/mysqld stop
  • mysqld_safe --skip-networking --skip-grant-tables
  • mysql -u root
  • mysql> use mysql;
  • mysql> update user set Password=PASSWORD('testpassword') where User='root';
  • mysql> quit
  • /etc/init.d/mysqld restart

No comments:

Post a Comment