ST Hosting Manual

Our manual

MySQL New Root Password

MySQL - New root password


General

If you have forgotten your MySQL root password, you can reset it really easily.

Important instructions for the tutorial

This tutorial only applies to Linux distributions, which uses the MSQY-server.
The # implies by default that in most cases, a console-command has to be accomplished with root privileges.
The $ implies by default that this command can be accomplished with standard user-rights.

Password

First, you have to stop the MySQL server and restart it in safe mode with the option to ignore the right tables.
# /etc/init.d/mysql stop
# mysqld_safe --skip-grant-tables
A shell program will open immediately, please do not close it.

New password

Please open a second SSH2 connection or a second console. The MySQL server runs in safemode, this is required because it is in the first shell.
Please use the following commands to reset your password:
# mysql –u root
# update user set password=PASSWORD('newpassword') where user='root';
# flush privileges;
# quit
The password of the root-user has been changed already into your new password. In addition you can close the second console now.

How to terminate the Safemode:

Go back to your first console. You can terminate the safe mode from the MySQL server with the command CTRL + C.
Ater that please restart the MySQL server:
# /etc/init.d/mysql start
The reset is completed now and the root-user has the new password.