Posts Tagged reset
Lost your mysql root password?
Posted by Robbie Scourou in of interest on February 3rd, 2010
Thought I would make a short instructive post as twice in the last month or so I’ve seen people come across this problem and not know how to resolve it. In one instance, the user had re-installed mysql and stuffed the server slightly.
If you have command line access to the server, and can login as a root user (or use sudo), do the following to reset your mysql root password.
- Stop the mysql server, either by directly killing it, or using a startup script (recommended).
- Create a text file on the server with the following in it (replace “somepassword” with your new password):
UPDATE mysql.user SET Password=PASSWORD('somepassword') WHERE User='root'; FLUSH PRIVILEGES; - Start the mysql server manually, using the –init-file switch:
mysqld_safe --init-file=/path/to/file/created/above &
- Your mysql root password should now be reset, test it out.
- If you can connect using the new authentication details, delete the created file, and then stop the mysqld service and start again using the correct startup scripts for your system
Simple as that. No need to re-install any software, nuke your data, or spend longer then 15 mins fixing the problem.