Tips# hack the mysql root password

      Comments Off on Tips# hack the mysql root password

logomysqlYesterday i  need to make some imports in the one of the Mysql Databases on development servers.

My collegs forgot t save the root password in the password databases and of course forget the password.

So i need to hack it. Its not so very difficult if you are root or securelly you have via sudo root access.

Let’s se it the commands:

1. Stop the MySQL instances:

/etc/init.d/mysql stop

2. Start the MySQL safe mode instance

mysqld_safe --skip-grant-tables

3. Open a new terminal to log in as root or add the & for the previous command.
Set the password and UPDATE the privileges.

mysql -u root
mysql>UPDATE mysql.user SET Password=PASSWORD('my_new_password') WHERE User='root';
mysql>FLUSH PRIVILEGES;
mysql>exit

4. The root password is changed to ‘my_new_password’

Notes:

If you have more root users account (ex. if you use different interface access configuration) all password is changing, maybe can you add following command

UPDATE mysql.user SET Password=PASSWORD('my_new_password') WHERE (User='root' and host='testPC_IP');