WordPress Tips When Using Secured MySQL

When you use secured MySQL for your database, like Vanderbilt ITS servers, installing WordPress causes one peculiar problem that can be a pain to debug. Or at least it was for me. I couldn’t find any documentation anywhere. Fortunately, one of the ITS server admins had alerted me that the standard php mysql_connect function needs fine-tuning to connect to their server, and I guessed that was the issue with WordPress. Specifically you need to add the MYSQL_CLIENT_SSL constant at the end.

In WordPress, the file you have to update is wp-db.php in the wp-includes includes folder. As of today it’s found on line 69. Find the line that reads:

$this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword);

Replace it with:

$this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword, true, MYSQL_CLIENT_SSL);

That’s all there is to it.

But as long as I’m blogging about this, I thought I’d give those of you having to upgrade WordPress my list of things to do. (I wrote it down so I don’t have to rethink it with every upgrade.)

Upgrading WordPress With a Secured MySQL Server

  1. Download and unzip the latest upgrade.
  2. Rename your current blog folder (local side) something like blog.old. Put the newly downloaded and unpacked folder in its place (being sure to rename it as needed).
  3. Review the readme file. Assuming upgrade instructions are the same as always, in the new folder….
  4. Copy your old wp-config.php
  5. Copy your old wp-content/plugins
  6. Copy your old wp-content/themes/
  7. Edit wp-includes/wp-db.php (see above)
  8. Continue following the readme instructions, which usually means uploading the new files and pointing your browser to /wp-admin/upgrade.php

One last step: thank Vanderbilt ITS for their help and support with this kind of work. They rock.

0 comments ↓

There are no comments yet...Kick things off by filling out the form below.

Leave a Comment