CyberPanel – Update MySQL root Password

Change Mysql Root Password Cyberpanel

CyberPanel provides an intuitive interface to host our websites. It uses MariaDB and requires root user to create database schemas and database users. Sometimes, we change MySQL root password and in that case, we have to update the same into CyberPanel configuration.

Recommended Reading: How to Change or Reset MySQL root Password

Updating MySQL root Password in CyberPanel

CyberPanel stores MySQL root password into two files.

  1. /etc/cyberpanel/mysqlPassword
  2. /usr/local/CyberCP/CyberCP/settings.py

1. Update MySQL root Password in mysqlPassword File

This file contains MySQL root password. Just open the file into your favorite editor and update it with the new root password.

2. Update MySQL root Password in settings.py File

This file contains Django settings. It has a section for database schema and user details. Just open this file and update the root password in the DATABASES section.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'cyberpanel',
        'USER': 'cyberpanel',
        'PASSWORD': 'Q02PhIk8rKYwnJ',
        'HOST': 'localhost',
        'PORT': '',
    },
    'rootdb': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'mysql',
        'USER': 'root',
        'PASSWORD': 'qwerty2022',
        'HOST': 'localhost',
        'PORT': '',
    },
}

The “mysql” database schema is used by the MySQL server, it holds all the users and their privileges details.

The “cyberpanel” database is used by the CyberPanel software.

Tip: If you change the “cyberpanel” user password in the MySQL server, you just need to change it in this file.

3. Restart the CyberPanel Service

# systemctl restart lscpd.service

That’s it. We have successfully updated the root password in the CyberPanel. You can login to the CyberPanel dashboard and create a test database to confirm it.

NOTE: If you have /home/cyberpanel/.my.cnf file present (older installations), then update the root password there also.

Bonus Tip: Changing MySQL Server Port in CyberPanel

By default, MySQL runs on 3306 port. But, if you are changing it for some reason, then you have to inform CyberPanel about it too.

Just update the new port number in the /usr/local/CyberCP/CyberCP/settings.py file DATABASES section and restart the CyberPanel service.

Leave a Comment

Your email address will not be published.