When using aaPanel, many people will often encounter the case that the website is operating normally and suddenly encounters an error message that cannot connect to the MySQL database. On WordPress, this error will show up with the message “Error establishing a database connection“.
The reason is that when installing the MySQL or MariaDB software package into aaPanel, it will automatically calculate the MySQL database configuration based on the amount of RAM on the server and often MySQL will use more RAM than expected.
To fix this error, go to App Store => MySQL and press the Settings button.
Next, click Optimization.
If your VPS has 3GB of RAM or more, you can select the Optimization plan item that matches the amount of RAM you want to allocate to MySQL. The RAM used for MySQL should only be about 40% of the total RAM available on the server.
In case the VPS you use has about 1-2GB of RAM, you should adjust the parameters manually, lowering all the parameters so that the Max RAM usage section shows using about 300MB to 500MB is reasonable.
After you have selected the parameters, you return to the Service menu and proceed to restart MySQL.
Refer to the top VPS service in Vietnam here!
Wishing you success!