database

How do I reset my MySQL root password if I have forgotten it?

1) Login to mysql server, type the following command at shell prompt:
# /etc/init.d/mysql stop

2) Start mysqld_safe using the command below:
# mysqld_safe –skip-grant-tables &

3) Login to mysql:
# mysql -u root mysql

4) To change the root password to null, do the following:

mysql> update user set password=PASSWORD(“NEWPASSWORD”) where User=’root’;

5) Reload the privileges:

mysql> flush privileges;
mysql> quit

6) /etc/init.d/mysqld restart

7) If you set the password to null, you should be able to login like this:

mysql -uroot

otherwise

mysql -uroot -p

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

To Top