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
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