Home » Quick Tips

Secure Database Connections in WordPress

Posted 6 Mar 2010 | No Comments | 246 views
Secure Database Connections in WordPress

If you are setting up a WordPress site with an SSL certificate in a shared environment such as an ISP or hosting center, one of the things that you need to consider is the connectivity to your database. If you database is running locally on the server, then protecting your database is easy.  Configure it to listen on a socket, and configure your firewall appropriately.

If your database is running on another server, then the database connections should also use SSL. (Following the age old adage: Encryption in the front, encryption in the back.) This will ensure data in transit is protected end-to-end.

Edit the wp-includes/wp-db.php file.  Find this line:

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

And modify it to look like this:

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

As an added precaution, when setting up the database access, add REQUIRE SSL to the GRANT statement.

Related Posts

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.