content:en_us:kb_troubleshooting_resetting_the_mysql_root_password

Reset Root MySQL Password

This document provides step-by-step instructions on how to reset the root password for the MySQL or System MySQL database on ClearOS 6.

MySQL

To reset the MySQL root password, you need to open a couple of command line terminals. On the first terminal, stop the running database:

service mysqld stop

Next, start the MySQL server in passwordless mode:

su -s /bin/sh -c '/usr/bin/mysqld_safe --skip-grant-tables' mysql

At this point you have MySQL running, but passwords are not required. On your second terminal, reset the root password with:

mysql -uroot -e "update user set password=password('my_password') where user='root'" mysql

Change my_password to a suitable root password of your choosing. Back on your first terminal, hit Ctrl-C to stop the passwordless MySQL server and then restart (yes, restart not start) MySQL in normal mode:

service mysqld restart

System MySQL

The procedure for resetting the built-in System MySQL is similar, but the paths, permissions and password handling are a little different. To reset the System MySQL root password, you need to open a couple of command line terminals. On the first terminal, stop the running database:

service system-mysqld stop

Next, start the MySQL server in passwordless mode:

su -s /bin/sh -c '/usr/clearos/sandbox/usr/bin/mysqld_safe --skip-grant-tables' system-mysql

At this point you have System MySQL running, but passwords are not required. On your second terminal, lookup the root password that was used to bootstrap the system database when it was created:

cat /var/clearos/system_database/root

Now use this password in place of my_password in the command below:

/usr/clearos/sandbox/usr/bin/mysql -uroot  -e "update user set password=password('my_password') where user='root'" mysql

Back on your first terminal, hit Ctrl-C to stop the passwordless System MySQL server and then restart (yes, restart not start) System MySQL in normal mode:

service system-mysqld restart

Help

content/en_us/kb_troubleshooting_resetting_the_mysql_root_password.txt · Last modified: 2018/06/05 07:59 by nickh