The MySQL password is stored in a different place than other system and user accounts and passwords. For this reason, it is set when you first implement start MySQL. Even though the administrative user of MySQL is called root, it is a good idea to use a different password for the MySQL for the root user and a separate password for the root user of MySQL.
<note warning>Resetting the password for root for MySQL will break any applications that use this account. For this reason and other security reasons, it is best to set up applications to use a separate account for database manipulation</note>
Log into the command line of ClearOS using one of the following methods:
If this is the first time you have logged into your server through this manner, you will be prompted to accept the identification of this server. Once you do this and are logged in, perform the following commands to reset the administrator password.
service mysqld stop
This stops the mysql service.
/usr/bin/mysqld_safe --skip-grant-tables &
This starts the MySQL daemon in the background and skips the authentication mechanisms.
Starts the commandline version of the MySQL client. Your prompt will change from [root@server ~]# to mysql>.
<note>MySQL uses a command language and syntax that is very specifically formatted. Many of the commands must end in a semi-colon. The syntax can also use parenthesis, double-quotes, and single quotes.</note>
This changes the commands to be issued from the 'mysql' database which is the database that mysql uses to run internal operations including user permissions and rights.
update user set password=password('newpassword') where user='root' and host='localhost';
This command sets the password for the root account to be newpassword. Feel free to change the syntax or use WebConfig to change it again later.
This command reprocesses the privilege database and applies the change you just made.
This will exit the text based mysql client. Your prompt will change from mysql> to [root@server ~]#.
service mysqld stop
This stops the permission-disabled version of the database that we are currently running. Alternately, you can stop MySQL from the Webconfig.
service mysqld start
This starts the MySQL daemon in its default mode which has all the permission structure in place (only this time you now know what the password is for the root account :) .) Alternately, you can start MySQL from the Webconfig.
This exits your logged in session from the console or from SSH.