MySQL Configuration Error with remote db host in settings.py and db user creation

Machine: LXD Container
Operating System: Rocky Linux 8
Cyberpanel Version: 2.3.4
MariaDB Version: 10.11.4
MySQL Host: 192.168.100.10
Cyberpanel Host: 192.168.100.20

Hello all,

when installing Cyberpanel with the script and MySQL on a remote host, the script on my opinion misconfigures /usr/local/CyberCP/CyberCP/settings.py which causes the a 500 error because Cyberpanel cannot read/write on the database “cyberpanel”.

The IP of the remote MySQL Host is correctly configured for the root user (local IP of container running MariaDB). But for the cyberpanel database it sets the public IP:

DATABASES = {
‘default’: {
‘ENGINE’: ‘django.db.backends.mysql’,
‘NAME’: ‘cyberpanel’,
‘USER’: ‘cyberpanel’,
‘PASSWORD’: ‘XXXXXXXX’,
‘HOST’: ‘1.2.3.4’, ← public IP of LXD host
‘PORT’:‘3306’
},
‘rootdb’: {
‘ENGINE’: ‘django.db.backends.mysql’,
‘NAME’: ‘mysql’,
‘USER’: ‘root’,
‘PASSWORD’: ‘XXXXXXXX’,
‘HOST’: ‘192.168. 100.10’, ← local IP of LXD Database Container
‘PORT’:‘3306’,
},
}

The cyberpanel user created on the database container is granted all privileges on the public IP, not on the local IP as specified in the set up script as it should to in order to be able to read/write the database.

So the remote cyberpanel database cannot be accessed from the cyberpanel container which causes the 500 error on access of the panel (http://192.168.100.20:8090).

I tried to simply update /usr/local/CyberCP/CyberCP/settings.py and grant the cyberpanel user all privileges on the local IP as well but debug mode then shows

ProgrammingError at /
(1146, “Table ‘cyberpanel.django_session’ doesn’t exist”)

I assume that because of the public IP Cyberpanel could not initially create all database tables and data.

What could I do?
Does the script has to be adapted?

Thanks for helping!

Magnus

Issue opened on github [BUG] MySQL Configuration Error with remote db host in settings.py and db user creation · Issue #1125 · usmannasir/cyberpanel · GitHub

1 Like