enabling ssl connection from wordpress to mysql

13,829

Solution 1

Edit wp-config.php

Add following line:

define('MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL);

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

define('MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT);

Tested on WordPress version 5.2.

Solution 2

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

https://wordpress.org/plugins/secure-db-connection/

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

Share:
13,829

Related videos on Youtube

Anadi Misra
Author by

Anadi Misra

perennial fiddler, typos infected. I mostly keep programming to learn new language; and so that I don't look a fool when I'm talking to the real deal guys, the developers :-)

Updated on September 18, 2022

Comments

  • Anadi Misra
    Anadi Misra almost 2 years

    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?

  • Jenny D
    Jenny D about 7 years
    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.
  • MrMesees
    MrMesees about 7 years
    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
  • EEAA
    EEAA about 7 years
    Yes, that's what @JennyD is saying. Link-only answers become useless when the original content moves of goes away.
  • MrMesees
    MrMesees about 7 years
    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
    MrMesees about 7 years
    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.