Changing the MySQL Root Password

Situation 1 Made a Root Password Mistake at Install Time

1 - Start MySQL without password checkings

Start a session with screen (or 2 ssh) so you are logged twice (once for start/stop the daemon, once for doing the password change).

You need to /etc/init.d/mysql stop before you start mysqld_safe ...

Then start mysql without password checks:

mysqld_safe --skip-grant-tables

2 - Changing the mysql root password

Log in the mysql interactive prompt as root (do it on another screen):

mysql -uroot -Dmysql -p

just hit enter when it prompt for password.

Then type:

   UPDATE user SET Password=PASSWORD('YOUR-NEW-ROOT-PASS') WHERE User='root';
   FLUSH PRIVILEGES;

3 - Restart mysql

Go on the screen where you started the mysql daemon, and type CONTROL-C. Then restart mysql in the normal mode: /etc/init.d/mysql start

When you will setup DTC again, don't ask for mysql password change, as you just did it !

Situation 2 Changing the Root Password

1 Update the mysql root password

Log into the mysql database as root:

mysql -uroot -Dmysql -p

Update the password

   UPDATE user SET Password=PASSWORD('YOUR-NEW-ROOT-PASS') WHERE User='root';
   FLUSH PRIVILEGES;
   quit;

2 Change DTC's password

Open the file:

   /usr/share/dtc/shared/mysql_config.php 

Change the line:

   $conf_mysql_pass="YOUR-NEW-ROOT-PASS"; 

Its prolly safest to now restart apache:

   /etc/init.d/apache2 restart  (or whatever your apache cmd is)

Check that you can log into your DTC admin and client pages. If all went well, you should have no errors. If you get errors, repeat the above steps. Also ensure that the password in the mysql_config.php has correct PHP syntax: i.e. All $ are \$ and \ are \\ etc

Editing this page means accepting its license.

Page last modified on August 27, 2007, at 12:35 PM EST