I have been searching on how to configure wordpress to connect to mysql db over ssl, however most of the example are about three to five years old e.g. this wordpress support topic

my wordpress version is 4.5.2 and obviusly the code and settings is nothing like what I in examples all over forums, is there a more relevant example on how to fix settings in wp-settings.php and wp-includes/wp-db.php to ensure secure connection to a remote MySql?

  • 2
    It seems to me like overkill to add an SSL layer on each database call. You'll regret it too soon to spend five more minutes on solving it this way. A much better solution would be to setup a VPN connection between both servers. This way, the MySQL connection is secured by directing it through the VPN, and all operations go much faster. May 23, 2016 at 4:24
  • @JuliePelletier the SSL handshake delay can be avoided by using persistent connections.But this cannot be done with some PHP setups, ie. using CGI SAPI. May 23, 2016 at 5:38
  • It's about trade offs, between moving parts of VPN & tunnels etc, and SSL, I would like to go with the latter :-) May 23, 2016 at 14:05
  • I'm curious what is so criticial in your Wordpress install it needs SSL, and why you're using an untrusted network? This is a valid pattern for enterprise apps in shared data centers where confidential information is in play, but is overkill for many situations.
    – Tim
    May 23, 2016 at 19:58
  • 1
    I am on cloud hosting, can't keep all eggs in single basket, we have PIIs in the database, hence the SSL part May 24, 2016 at 4:48

4 Answers 4


Edit wp-config.php

Add following line:


If your database(MySQL 5.6 or later) use a self-assigned certificate, you may try:


Tested on WordPress version 5.2.


For those looking for a way to do this w/o hacking core or rolling your own plugin:


Created by the dev who initially reported the issue in WordPress: https://core.trac.wordpress.org/ticket/28625


Pretty sure this is answered best here you basically add a filter, and the details to the SSL certificate details in wp-config.php

There is also a plugin on the wordpress.org repository here

  • 1
    Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – Jenny D
    Jun 2, 2017 at 16:24
  • Are you suggesting I should duplicate content that may change based upon third-party decision making simply to boost StackOverflow keywords? I was merely trying to provide an answer that stood the test of time; feel free to make the edits you desire but the downvote and needlessly pedantic comment are not appreciated
    – MrMesees
    Jun 13, 2017 at 11:45
  • 1
    Yes, that's what @JennyD is saying. Link-only answers become useless when the original content moves of goes away.
    – EEAA
    Jun 13, 2017 at 11:55
  • I'm sorry but that ignores fundamentals of the web, such as being able to use archive.org, or the documentation author simply updating their links. I absolutely accept that if someone links to my personal site dead links may be a factor. If I link to MySQL 5.5 docs, or latest, it's less likely the URL will be broken than the duplicate content obsolete. You're arguing to create a network graph problem.
    – MrMesees
    Jun 14, 2017 at 12:51
  • Put in a simpler way, if the link breaks there is one place to change it (on the site of the link). If SO answer + quora + every other platform has a change then there are N places to change that content.
    – MrMesees
    Jun 14, 2017 at 12:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .