How to Reset a MySQL Password in 5 Easy Steps
1. Stop the mysqld daemon process.
2. Start the mysqld daemon process with the –skip-grant-tables option.
3. Start the mysql client with the -u root option.
4. Execute the UPDATE mysql.user SET Password=PASSWORD(‘password’) WHERE User=’root’;
5. Execute the FLUSH PRIVILEGES; command.
[root@localhost init.d]# ./mysqld stop
Stopping MySQL: [ OK ]
[root@localhost init.d]# ./mysqld start –skip-grant-tables
[root@localhost init.d]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 4.1.20
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql> connect cacti
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Connection id: 25
Current database: cacti
mysql> update user_auth set password=md5(‘admin’) where username=’admin’;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0