Unable to connect MYSQL with any CMS or Custom Scrpit

OS type and version Ubuntu Linux 20.04.4
Webmin version 1.999
Virtualmin version 7.1-1
Related packages WORDPRESS and Other CMS not connect with database

Also, try install manually and automaticly via Install Scripts not working.

After wordpress show page like that all WP confirgation is correct.

Error establishing a database connection

This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at localhost. This could mean your host’s database server is down.

  • Are you sure you have the correct username and password?
  • Are you sure you have typed the correct hostname?
  • Are you sure the database server is running?

If you’re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

Can you see the database, and see that it has contents in the Webmin MySQL module?

Can you connect to the database on the command line using the credentials for that domain?

It’s new installation via Virtualmin error bug

Open your wp-config.php file and note down the DB name, DB username and DB password then:

  1. In your VIrtualmin dashboard:
    a. go to Edit Databases and see if the “DB name” from the wp-config exists or not.
    b. got to Edit Users and see if the “DB username” from the wp-config exists or not.

If everything exists after checking 1a and 1b:

  1. run the following command replacing each $ with the info from your wp-config to see if mysql connects or not:
mysql --user=$USER --password=$PASSWORD $DBNAME

Every detail in wp-config.php is correct cross-checked many times. this problem in the new installation.

MYSQL not connect with web server i hope you understand

What did you get when you run the following?

mysql --user=$USER --password=$PASSWORD $DBNAME

1 Like

No one here has suggested checking wp-config.php. We’re trying to help you figure out what’s actually wrong, so we can help you fix it.

assuming you did check these and still fail, do you create virtual server with chroot enabled? If so, would you try to replace in wp-config.php: DB_HOST = localhost into DB_HOST =

I had this … it turned out to be the login plugin mysql was using changing this to mysql_native_password from sha_256_password fixed it for me

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.