Skip to content

forget mysql root password

follow this STEPS and reset your root PASSWORD

1.) root@kraneis:~# /usr/bin/mysqld_safe –skip-grant-tables –user=root &
[1] 13245
root@kraneis:~# nohup: ignoring input and redirecting stderr to stdout
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[13287]: started


root@kraneis:~# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.51a-3ubuntu5.4 (Ubuntu)

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

2.) mysql> UPDATE mysql.user SET Password=PASSWORD(‘XXXXXXXX’) where User=’root’;
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

3.) mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
4.) root@kraneis:~# /etc/init.d/mysql restart
* Stopping MySQL database server mysqld               STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[13374]: ended
[ OK ]
* Starting MySQL database server mysqld                                                              [ OK ]
* Checking for corrupt, not cleanly closed and upgrade needing tables.
[1]+  Done                    /usr/bin/mysqld_safe –skip-grant-tables –user=root
root@kraneis:~# mysql -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.0.51a-3ubuntu5.4 (Ubuntu)

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql>