Reset Root MySQL Password

by damonp on September 6, 2005

1. Gracefully stop the MySQL server. On most Linux systems:

/etc/init.d/mysql stop

2. Restart mysqld with the –skip-grant-tables option.

safe_mysqld –skip-grant-tables

3. Set a new password with the mysqladmin password command.

mysqladmin -u root password ‘newpassword’

4. Now stop mysqld and restart it normally.

/etc/init.d/mysql restart

5. After this, you should be able to connect using the new password.

Alternatively, you can set the new password using the MySQL client:

1. Repeat steps 1 and 2 above.

2. Connect to the mysqld server with:

mysql -u root mysql

3. Issue the following commands in the MySQL client:

UPDATE user SET Password=PASSWORD('newpassword') WHERE User='root';

4. Exit out of the MySQL client and restart the server as above.

5. You can now stop mysqld and restart it normally.

Popularity: 13% [?]

Leave a Comment

Previous post:

Next post: