Howto: How to Reset the MySQL Root Password

The following procedure can be used to reset the password for any MySQL root accounts on Linux and Unix (*nix). The instructions assume that you have got the proper permissions on the host system.

Stop the MySQL daemon process

sudo /etc/init.d/mysql stop

Create a text file /home/me/mysql.sql and place the following statements in it. Replace the password with the password that you want to use

UPDATE mysql.user SET Password=PASSWORD('a_new_password') WHERE User='root';
FLUSH PRIVILEGES;

The UPDATE and FLUSH statements each must be written on a single line. The UPDATE statement resets the password for all existing root accounts, and the FLUSH statement tells the server to reload the grant tables into memory.

Start the MySQL server with the special –init-file option

mysqld_safe --init-file=/home/me/mysql.sql

Press Ctrl+C and then start the MySQL server again by /etc/init.d/mysql start and you are done.

Related posts:

  1. Howto Recover a Linux Root Password
  2. Executing SQL Statements from a Text File
  3. How to hack Windows password with Ophcrack
  4. Crack Windows Password
  5. Optimize MySQL Performance With MySQLTuner
  6. Optimize MySQL for Low Memory Use
  7. How to reset a Nokia
  8. MySQL Optimization and Performance Tips
  9. How to do MySQL replication (dual-master / multi-master)
  10. Howto: Resize Xen Loop Disk Image

Popular Related Items »

Leave a Comment