Webhosting Blog

Reset MySql root password

In order to reset your root mysql password follow following steps:

1) Login to the server as root
2) Stop the mysql service.

[root@server~]# service mysql stop

3)Start the MySQL server in background with the –skip-grant-tables option so that it should not prompt you for the password.

[root@server~]# mysqld_safe –skip-grant-tables &
[1] 7086

4)Connect to mysql server as the root user.

[root@server~]# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2541741
Server version: 5.0.91-community MySQL Community Edition (GPL)

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

5) Now reset the password for the root user with following commands:

mysql> use mysql;
mysql> update user set password=PASSWORD(“NEW-ROOT-PASSWORD”) where User=’root’;

Query OK, 2 rows affected (0.02 sec)
Rows matched: 2  Changed: 2  Warnings: 0

mysql> flush privileges;

Query OK, 0 rows affected (0.01 sec)

mysql> quit

6) Now Exit and restart the MySQL server.

[root@server~]# # service mysql stop

7) Now restart the mysql service and try login with the new password.

[root@server~]# service mysql start
[root@server~]# mysql -u root -p


One response

  1. Pingback: MySql: query result in csv file using command « Php Bugs

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s