MySQL over SSL

Discussion in 'Installation/Configuration' started by bschultz, Aug 20, 2008.

  1. bschultz

    bschultz Member

    Can someone please explain to me how to get MySQL running over an SSL connection? I'm running Etch with current versions of PHP and MySQL.

    Thanks.
     
  2. topdog

    topdog Active Member HowtoForge Supporter

    Your mysql needs to be linked to openssl, am not sure of debian but the centos version is not linked. Then you need certificates for the server. How to set that up is explained here http://dev.mysql.com/doc/refman/5.0/en/secure-using-ssl.html

    On the PHP side you need to set the extention constants
    Code:
    MYSQL_CLIENT_SSL - mysql
    MYSQLI_CLIENT_SSL - mysqli
    You will need to point to your certificates

    Code:
    [client]
     ssl-ca=/etc/mysql/cacert.pem
     ssl-cert=/etc/mysql/client-cert.pem
     ssl-key=/etc/mysql/client-key.pem
    
     [mysqld]
     ssl-ca=/etc/mysql/cacert.pem
     ssl-cert=/etc/mysql/server-cert.pem
     ssl-key=/etc/mysql/server-key.pem
     
  3. bschultz

    bschultz Member

    Alright...I'm now able to connect to the mysql server (at least I'm not getting any connect errors) but it's still not working...


    no errors with this code...but no insert into the db either!


    Code:
    $link = mysqli_connect("localhost", "xxx", "xxx", "paypal");
    
    /* check connection */
    if (mysqli_connect_errno()) {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit();
    }
    
    
    $query = "insert IGNORE into purchases values ('$pdate', '$first_name', '$last_name', '$payer_status', '$payer_email', '$payer_id', '$payment_status', '$amount', '$txn_id', '$txn_type', '$payment_type', '$custom', '$mc_fee', '$pending_reason', '$verify_sign', '$pass', '$cell', '$provider')";
    
    mysqli_query($link, $query);
    
    echo "<p>Thank You, you need to set your password to listen.</p><meta http-equiv=Refresh content=3;url='page.php?page=setpassword'>";
    
    
    
    /* close connection */
    mysqli_close($link);
    ?>
    
    All of the inserts are defined properly before the code quoted above. Thanks for any help!
     
  4. Ben

    Ben ISPConfig Developer ISPConfig Developer

    But you did not check the return value of your mysqli_query.
    For debug purposes the easiest is to wrap a var_dump( ) around to see what's the matter.
     

Share This Page