Connecting to MySQL via SSL using PHP

后端 未结 1 782
灰色年华
灰色年华 2020-12-18 12:19

I\'m writing my first script that will connect via SSL to a MySQL database. I have been doing a lot of reading on the subject and have come across many options on how to set

相关标签:
1条回答
  • 2020-12-18 12:59

    The MySQL server is on the same machine as the script. My SSL Certificate is installed. Is it secure to simply connect to the database via a page that is using SSL with the following code?

    If you control the server(VPS) and PHP is on the same machine as MySQL(only need to allow connections from same machine) than it is pointless to use SSL for MySQL and will only result in overhead. You should just use firewall to protect MySQL like you should also do with memcached.

    Otherwise you could read this section from MySQL to configure SSL. I think involves a little bit more than just $con = mysql_connect("localhost", "username", "password", MYSQL_CLIENT_SSL); . For example you need to configure your SSL Certificate:

    mysqld --ssl-ca=ca-cert.pem \
           --ssl-cert=server-cert.pem \
           --ssl-key=server-key.pem
    
    0 讨论(0)
提交回复
热议问题