- How to reset the MySQL password
- If the password is known, it is modified by the following way;
- [email protected]:~$ mysql --user=root--pass mysql
- Enter Password:
- MySQL> Update user set password=Password (' New-password-here ') WHERE user=' root ';
- Query OK, 2 rows affected (0.04 sec)
- Rows matched:2 Changed:2 warnings:0
- MySQL> Flush privileges;
- Query OK, 0 rows affected (0.02 sec)
- MySQL> Exit
- Bye
- If you forget your password, stop MySQL first and then add the parameter skip-grant-tables to restart MySQL server
- [Email protected]:~#/etc/init.d/mysql Stop
- Now your should start up the database in the background, via the Mysqld_safe command:
- [Email protected]:~#/usr/bin/mysqld_safe--skip-grant-tables &
- [1] 4271
- Starting mysqld daemon with databases From/var/lib/mysql
- MYSQLD_SAFE[6763]: Started
- Then log in to MySQL, change the password
- [email protected]:~$ mysql --user=root mysql
- Enter Password:
- MySQL> Update user set password=Password (' New-password-here ') WHERE user=' root ';
- Query OK, 2 rows affected (0.04 sec)
- Rows matched:2 Changed:2 warnings:0
- MySQL> Flush privileges;
- Query OK, 0 rows affected (0.02 sec)
- MySQL> Exit
- Bye
- Finally, restart MySQL server.
- [Email protected]:~#/etc/init.d/mysql Start
- Starting MySQL database Server:mysqld.
- Checking for corrupt, not cleanly closed and upgrade needing tables.
- Login with the new password to verify
- [email protected]:~# mysql --user=root --pass=new-password-here
- Welcome to the MySQL Monitor. Commands End With; or \g.
- Your MySQL Connection ID is 5 to server Version:5.0.24a-debian_4-log
- Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the buffer.
- MySQL> Exit
- Bye
How to reset the MySQL password