Developers Documentation

×

Warning

301 error for file:https://clearos.com/dokuwiki2/lib/exe/css.php?t=dokuwiki&tseed=82873f9c9a1f5784b951644363f20ef8

User Tools

Site Tools


Forgot MYSQL Password

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.

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

Recover Lost Password

Log into the command line of ClearOS using one of the following methods:

  • From the console of the server, select one of the available command line consoles (Ctrl+Alt+F2, Ctrl+Alt+F3…)
  • From Windows, download the Windows installer of PuTTY and SSH to the IP or hostname of the server
  • From a Mac or Linux/Unix workstation, use the built-in terminal application. On Mac this is found in Applications » Utilities » Terminal. SSH to your server by running replace ip_address_or_hostname):
ssh root@//ip_address_or_hostname

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.

ClearOS 6.x:

service mysqld stop

ClearOS 7.x

service mariadb 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.

mysql

Starts the commandline version of the MySQL client. Your prompt will change from [root@server ~]# to mysql>.

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.

use mysql;

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.

flush privileges;

This command reprocesses the privilege database and applies the change you just made.

quit

This will exit the text based mysql client. Your prompt will change from mysql> to [root@server ~]#.

ClearOS 6.x

service mysqld stop

ClearOS 7.x

service mariadb stop

This stops the permission-disabled version of the database that we are currently running. Alternately, you can stop MySQL from the Webconfig.

ClearOS 6.x

service mysqld start

ClearOS 7.x

service mariadb 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.

exit

This exits your logged in session from the console or from SSH.

content/en_us/kb_howtos_forgot_mysql_password.txt · Last modified: 2020/01/27 01:28 by nickh

https://clearos.com/dokuwiki2/lib/exe/indexer.php?id=content%3Aen_us%3Akb_howtos_forgot_mysql_password&1710844169