To change MySQL root password in CyberPanel we need to update it’s configuration.
CyberPanel stores MySQL root password into two files:
- /etc/cyberpanel/mysqlPassword
- /usr/local/CyberCP/CyberCP/settings.py
mysqlPassword File contains the MySQL root password and to change the password we have to edit this file.
After changing the password we need to update the settings.py file which holds Django settings.
Under DATABASES you can update the password.
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': '',
},
}
- cyberpanel database is used by the CyberPanel software.
- mysql database schema is used by the MySQL server and it holds all the users and their privileges details.
And finally after modifying these two files we need to restart the CyberPanel service:
systemctl restart lscpd.service
That’s it, we’ve just changed the MySQL root password in CyberPanel.
NOTE: In older versions of CyberPanel you also have to update the root password in /home/cyberpanel/.my.cnf
file.