MySQL Root Password Reset

When you try to install mysql using rpm  then some times you have faced password authentication problem. This is not an issue, it means your mysql server is working fine but need authentication to access it. So let us do the following:-

$ pkill -9 mysql

This is for killing the mysql process running in the server.

cat /root/.my.cnf

Please read the password from the above file, if it is cpanel server.

Now do the following command in the mysql prompt:-

$/usr/libexec/mysqld –skip-grant-tables –user=root &

This skip-grant-tables option causes the server not to use the privilege system at all. This gives anyone with access to the server unrestricted access to all databases.

Go back into MySQL with the client:

MySQL > UPDATE user SET Password=PASSWORD(‘YOUR_PASSWORD’)  WHERE Host=’localhost’ AND User=’root’;

You have now reset mysql root in the server. So you need to kill all the mysql process following command:-

$ killall mysqld

Start MySQL the normal way for your system.

/etc/init.d/mysqld start

You can now access mysql and  login as root using the password which you have set using UPDATE command.

Both comments and pings are currently closed.

Comments are closed.