How to use MYSQL_CLIENT_SSL parameter with mysql_connect () in PHP?

I have a mysql database CA certificate that I am trying to connect to (on Amazon rds). I cannot find a good example of how to connect to the mysql database using the php function mysql_connect () and use this ca certificate (stored in / home / username / mysql _ca_cert.pem) to connect.

Can someone help me with a simple example?

+7
source share
4 answers

mysql_connect () depreciates and is heavily hacked. Using it is stupid

<?php $pdo = new PDO('mysql:host=ip;dbname=db', 'user', 'pass', array( PDO::MYSQL_ATTR_SSL_KEY =>'/etc/mysql/ssl/client-key.pem', PDO::MYSQL_ATTR_SSL_CERT=>'/etc/mysql/ssl/client-cert.pem', PDO::MYSQL_ATTR_SSL_CA =>'/etc/mysql/ssl/ca-cert.pem' ) ); $statement = $pdo->query("SHOW TABLES;"); $row = $statement->fetch(PDO::FETCH_ASSOC); echo htmlentities($row['_message']); ?> 

http://www.php.net/manual/en/book.pdo.php

+1
source

This will be a connection using ssl cert servers, 2048 is the key

 $link=mysql_connect(host, user, password,true,2048); 
0
source
 $db = mysqlii_init(); $db->ssl_set('server-key.pem','server-cert.pem', 'cacert.pem', NULL, NULL); $db->real_connect('localhost','root','','mydb'); 

and then of course

 $db->close(); 

hope that helps :)

-one
source

You could probably try mysqli :: ssl_set

http://www.php.net/manual/en/mysqli.ssl-set.php

-2
source

All Articles