Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the hueman domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/CloudIngenium.com/htdocs/wp-includes/functions.php on line 6114
How to: Connect to a MySql server using SSL from a WordPress Site – Knowledge eXchange

How to: Connect to a MySql server using SSL from a WordPress Site

How to: Connect to a MySql server using SSL from a WordPress Site

Truly you could title this post simply How to Connect to a MySql server using SSL from a PHP application. The key is in the connection construct, which by default in WordPress it looks sort of like this:

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

So here comes the key to the whole business: You must use the “MYSQL_CLIENT_SSL” client flag to indicate PHP to use SSL. So, in the case of WordPress you could manually open the db.php file and make the manual edit or rely on the parameter $client_flags which is defined as follows:

$client_flags = defined( 'MYSQL_CLIENT_FLAGS' ) ? MYSQL_CLIENT_FLAGS : 0;

So what this means for you is that by defining MYSQL_CLIENT_FLAGS in something like your wp-config.php file you could set the flag to MYSQL_CLIENT_SSL effectively indicating PHP to connect to MySql via SSL. Below is a sample of what to add to your config file:

define(‘MYSQL_CLIENT_FLAGS’, MYSQL_CLIENT_SSL);

Hope this helps!

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.