local wordpress multisite not working on AWS development server “error establishing database connection”

wordpress.stackexchange https://wordpress.stackexchange.com/questions/344206

Question

I have a composer WP starter installation on my local mac using mamp. It works as expected. I'm using phpdotenv to hide my wp-config.php settings and I have the wordpress directory moved into a sub-directory under document root. I use a virtual host on the local mac dev2.domainname.com. I used wp db migrate pro to find and replace dev2 to dev3 as the domainname.com is the same on local and AWS. The only other difference is the database connection settings. I know the database connection settings are correct as I use them in the shell script that runs composer and installs wp using wp-cli. The script runs perfectly. But for some reason and I have looked at httpd.conf, .htaccess, .env settings, everything I can think of I get "error establishing a database connection". Any ideas on where to look or how to diagnose the problem? Thx

Was it helpful?

Solution

there are several reasons why you can get this type of error,

  • invalid credentials: this you said you have checked, so likely not the reason.
  • corrupt WP files: when moving server, it is possible that the files copied (zip archived) were somewhat corrupted. this would cause can such an error.
  • corrupted DB: again, the DB could have some issues with its installation. This may not be obvious when you are able to view your tables using a tool such as PhpMyAdmin, but it may still be there are some issues with it.

and of course your DB server could be down, but if you are able to access it using phpmyadmin then that ain't the case.

How to nail it down?

  1. I would first make a new installation of WP, setup it up as a multisite in the sub-folder. Get it to work by default. This rules out corrupted files.
  2. copy all your plugins across and activate them, this will ensure the files are not corrupt.
  3. create a new DB from your localhost copy, change the domain names in the DB (I use InterconnectIt's excellent Search & Replace tool.) Check the following tables have been properly changed (wp_site, wp_options (look at siteurl and home key values), and wp_blogs).
  4. and finally point your wp-config file to this new DB.

Hopefully it should all work, else, the issue is with the DB being corrupt, so you'll need to re-export it again and repeat step 3.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top