WordPress “Error establishing Database connection” and straight quotes

WordPress “Error establishing Database connection” and straight quotes

We’ve recently migrated our websites from 1and1 hosting to Amazon Web Services (AWS). Our sites are all WordPress based.

There were a couple of snags in the migration…but with all often performed procedures (we are not the first to migrate a WordPress site!), most could be solved by RTFM  (loosely: read the instructions) and don’t shoot yourself in the foot.

One very strange issue came up with the wp-config.php file. For those not initiated into WordPress configuration, this is the file that tells WordPress where to find the MySQL DB and what credentials to login with. I had to edit this file to change DB_NAME, DB_USER, DB_PASSWORD and DB_HOST due to the move.

I had backed up all of the files down to my laptop (a Mac Book Air) and edited the wp-config.php file with Test Edit.

Here is the file after edit. If you can see the problem, you have better eyes than I do.

CurlyQuote

Apparently when I edited the file on my MacBookAir, the default quotes, which are curly vs. straight were used. Linux/PHP apparently do not like these, as, after much gnashing of teeth and investigating, changing them to straight quotes cured my “DB Connection” error.

Straight quotes

Hopefully this will assist anyone else from too much banging their head against the wall during a migration.

The other issue I ran into in migration was “unable to create the folder uploads/2015/11” when posting images for this particular post. This is resolved by going to Settings/Media and correcting the upload folder for the new hosting service.

Leave a Reply

%d bloggers like this: