Blog

Restoring Access to MySQL

A step-by-step guide to restoring access to MySQL when the root password is unknown.

Dmytro
MySQL database recovery server maintenance Linux database administration

Restoring Access to MySQL

Today, several clients have reached out regarding issues related to MySQL. The diagnostics reveal that there are no references to the server in ispmgr.conf (the configuration file of the control panel), and the root password for MySQL is unknown. In such cases, we need to change the MySQL password to something known to us. Below are the steps for CentOS:

Resetting the MySQL Password

  1. Stop the MySQL service:
    service mysqld stop
    
  2. Start MySQL in safe mode:
    mysqld_safe --skip-grant-tables &
    
  3. Log in to MySQL:
    mysql -uroot mysql
    
  4. Set a new password for the root user:
    UPDATE mysql.user SET password=PASSWORD('new-password123') WHERE User='root';
    FLUSH PRIVILEGES;
    
  5. Exit the MySQL console client: Press Ctrl-D or type exit.
  6. Restart MySQL:
    /etc/init.d/mysqld restart
    

Updating the Configuration File

If the entry for your database server is missing in /usr/local/ispmgr/etc/ispmgr.conf, you will need to add it back:

DbServer "localhost" {
    Owner __Owner__
    AccessType allow
    ChangePassword 2012-10-27
    Hostname localhost
    Password new-password123
    SockPath /var/lib/mysql/mysql.sock
    Type mysql
    User root
}

Restarting the Control Panel

Finally, restart the control panel:

killall ispmgr

Check that “Database Servers” appears again in ISPManager Lite.

Need Help?

Our support team is available 24/7 to assist you with any questions or issues.

Contact Support