0

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

  • You may want to try to connect to 127.0.0.1:3306 instead of localhost. That did the job for me a while ago. Since you are on localhost and may run a new PHP version. – user3135691 Aug 2 at 7:46
  • Local runs perfectly it is the migration to dev3 on AWS that is not working. I trying one approach of assuming it is rewrite rules on the apache server so I'm copying my MAMP httpd.conf file to AWS and making all the necessary changes if that doesn't work I'm going to try the answer below from Aurovrata – dallasdawg Aug 2 at 14:31
0

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.

  • Well - great answer sometimes you get tunnel vision. I stopped the local load of the db and just ran the shell script installed all the plugins and themes through wp-cli but did not activate and it works perfectly - so need to figure out why the db load is messing everything up – dallasdawg Aug 2 at 19:37
  • glad you're on the right track. I know its not much consolation, but I have moved multisite installations from local to server multiple times and I have never got it to work right from the first attempt...its messy and tricky, so step by step is key. – Aurovrata Aug 3 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.