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!
Love
Can we use Let's Encrypt, the free and open certificate authority?
Hola! gracias por la info, me sirvió el comando sacandole el nombre del server. En mi caso, fue una migración…
Yes 3rd option helped me too. I removed the WC key Values from config file then started working.
I know this is from 2014. But really, thank you!