Brave Cobra's Hideout
If Linux doesn't have the solution, you have got the wrong problem.
HomeNews

News

Linux

Linux: Reset your MySQL root password

Contributed by bravecobra on Sep 20, 2010 - 05:11 AM

Linux

So, you've lost the password for the root user of you MySQL server. How stupid! Don't do it ever again! Well, you still have to reset the password now, don't you. I'll explain how it is done. The same will go for most other systems, only the startup and shutdown procedures might be slightly different.
First, shutdown the MySQL database and login as the root user on your Gentoo system.
/etc/init.d/mysql stop
After that you have to start MySQL in a way that ignores the current grant tables. Grant tables are used to authorise access to users.
mysqld --skip-grant-tables
Now, reset the root password
mysqladmin -u root flush-privileges password "newpwd"
mysqladmin -u root -h localhost flush-privileges password "newpwd"
With this brand new password set, shutdown MySQL.
mysqladmin -u root -p shutdown
Now it's time to bring your MySQL server back up for production use. You should never leave your server running with --skip-grant-tables enabled for that is a big security risk!
/etc/init.d/mysql start
That's all. Now don't forget your root password again. And if you do, you know where to find the tutorial on how to fix it.
 

Rating

  • Currently 0 / 5 Stars.

No comments posted yet.

Only logged in users are allowed to comment. Register or log in.