Submitted by ravisagar on Tue, 01/08/2008 - 04:08.
If you have forgotten your MySQL root password then don't worry. You can reset your lost password. Here is the procedure.
1. Login as root.
2. Kill running MySQL process and stop the MySQL service.
[[email protected] root]# killall mysqld
[[email protected] root]# /usr/libexec/mysqld -Sg --user=root &
3. Restart MySQL server with these parameters
[[email protected] root]# mysqld --skip-grant-tables --user=root
4. Manually set root password in the table "user" of "mysql" database.
[[email protected] root]# mysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1 to server version: 3.23.41
Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
mysql> USE mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> UPDATE user
-> SET password=password("newpassword")
-> 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.01 sec)
mysql> exit;
[[email protected] root]# killall mysqld
5. Restart MySQL again
[[email protected] root]# /etc/init.d/mysqld start
Now your root password is set and you can now login as root using the password you have just created.
[[email protected] root]# mysql -u root -p
Enter Password: "newpassword"
If you again forget your root password don't worry just check this link again :)
Recent comments
11 years 30 weeks ago
11 years 31 weeks ago
11 years 31 weeks ago
11 years 43 weeks ago
11 years 43 weeks ago
11 years 44 weeks ago
11 years 48 weeks ago