• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Unable to establish a connection to the database

kukwiak

New Pleskian
Server operating system version
CloudLinux 7.9
Plesk version and microupdate number
No plesk installed only WPToolkit
Hi,
On a newly configured hosting server based on cPanel, I started testing the WPToolkit tool. I installed all the necessary requirements, created a hosting account on which I want to install the site using the previously mentioned tool. Unfortunately, I get the following errors every time I try:
Error displayed in cPanel:
WordPress was installed with errors:
Error: Error establishing a database connection. This either means that the username and password information in your `wp-config.php` file is incorrect or that contact with the database server at `localhost:3306` could not be established. This could mean your host's database server is down.
Error from WPToolkit mainlog:
An error occurred while executing WP-CLI command for instance: WordPress installation #15. Error: Error establishing a database connection.
I was using MySQL 5.7 database which I had updated to version 8.0 - the same error occurred on both versions.
When creating a .php file with a test connection, the data is correct. The MySQL service is also enabled.
When I created the database, I saved the data to connect to it, and watching the log, as soon as it was created I connected to it seamlessly from the root CLI.
What can be caused by the occurrence of such an error?
 
Are we talking about cPanel or Plesk? As this is the Plesk forum it may not apply to your environment although WP Toolkit might appear similar.
 
We are talking about the installation of WPToolkit in cPanel based on CloudLinux 7.9.
This problem spends me sleepless nights, every tip can be at a premium.
 
Since you've mention cPanel more than a few times I'm incline to believe that you're using cPanel (maybe cPanel WHM?). Considering this forums is for Plesk the things mention will not be 1 to 1 with the likes of cPanel since they're 2 different products that's handled differently.

Only thing I can suggest is making sure your database username and password is correctly set in wp-config.php (reset the password if you have to and update wp-config.php with the new password), but otherwise your best bet would be to ask on the cPanel forums.
 
Yes, you are right scsa20, it is cPanel WHM, I inquired with cPanel support about this problem, the problem has been escalated to them, because so far they have not been able to help me.
The problem is that WPToolkit creates a new database and a new user. I performed such an action that I watched the log after creating the database and user, copied the data to the database and connected to it from the root CLI, there were no errors regarding this connection. The error also gave the following issue
contact with the database server at `localhost:3306` could not be established
to see if it was possible to connect to such a host, I created a database and user on a test account where the host was
"localhost:3306"
the connection was also made.
I wonder how WPToolkit connects to the database that he can not achieve this connection?

WPToolkit's abbreviated mainlog looks as follows:
[2023-04-26 15:48:52.748] DEBUG Enable heavy timeout for all WP-CLI operations running as part of an website installation operation
[2023-04-26 15:48:52.780] DEBUG Executing 'init-instance-object' step
[2023-04-26 15:48:55.175] DEBUG Executing 'hide-instance' step
[2023-04-26 15:48:55.286] DEBUG Executing 'download-package' step
[2023-04-26 15:48:55.364] INFO Deploy WordPress instance #15 into
[2023-04-26 15:48:56.217] DEBUG Downloading of WordPress 6.2 package will performed at 3 attempts.
[2023-04-26 15:48:56.217] DEBUG Start attempt 1 to download package using URL: https://wordpress.org/wordpress-6.2.zip
[2023-04-26 15:48:56.218] DEBUG Acquire lock 'download_package_wordpress-6.2.zip'
[2023-04-26 15:48:56.219] DEBUG Lock 'download_package_wordpress-6.2.zip' acquired successfully
[2023-04-26 15:48:56.219] DEBUG Release lock 'download_package_wordpress-6.2.zip'
[2023-04-26 15:49:17.231] DEBUG Skip verifying checksums of the files if they extracted from local cache.
[2023-04-26 15:49:17.308] DEBUG Executing 'create-db' step
[2023-04-26 15:49:17.380] DEBUG Creating WordPress instance #15 database
[2023-04-26 15:49:20.688] DEBUG Executing 'install-instance' step
[2023-04-26 15:49:20.762] DEBUG Install WordPress instance #15
[2023-04-26 15:49:20.776] DEBUG Detected HOME directory of 'ah100hostingrd': /home/ah100hostingrd
[2023-04-26 15:49:34.404] ERROR An error occurred while executing WP-CLI command for instance: WordPress installation. Error: Error establishing a database connection.
 
Although WP Toolkit is maintained for both panels, there are some differences. This here is the Plesk forum. Users using Plesk will probably not be able to assist with cPanel issues. cPanel has their own support forum, maybe you can try to ask there.
 
As Peter said, both panels has WP Toolkit but the way it's implemented and maintained is different. For example, if I wanted to use the WP Toolkit's CLI on a server running Plesk, I would just issue plesk ext wp-toolkit --wp-cli, I have no clue how to do the same in cPanel's WHM without doing a lot of research since I haven't touched cPanel in ages (last time I touched cPanel was long before WP Toolkit became a thing). For that very reason your best bet would be to ask for help over at the cPanel community forums or keep nagging cPanel's support since no one here would be able to assist effectively.
 
Back
Top