Home  >  Q&A  >  body text

Connect phpMyAdmin to MySQL server via SSL

I may be barking up the wrong tree... However, what I have is a MySQL server that only accepts connections from clients with valid SSL certificates (see this link). This works great for Rails, for example. My database is on a server and I have a Rails application that connects using a client certificate. Maybe not the fastest, but it works.

The configuration in

database.yml is as follows:

sslkey: /path/to/client-key.pem
sslcert: /path/to/client-cert.pem
sslca: /path/to/ca-cert.pem

The problem is that I want to host phpMyAdmin on the same server as the Rails application. I think phpMyAdmin is more limited in its connection options since I can't seem to find a way for it to connect using a client certificate. But I find it strange that googling doesn't turn up many answers on this question (which makes me wonder if I'm taking the wrong approach).

Obviously I could easily set up phpMyAdmin itself to be hosted behind an SSL certificate (which would encrypt requests between the client browser and my phpMyAdmin server), but I would like the phpMyAdmin <-> database connection to also is encrypted. < /p>

is it possible? Is this a bad design choice? Is there a better way?

P粉668019339P粉668019339332 days ago755

reply all(2)I'll reply

  • P粉806834059

    P粉8068340592023-10-24 00:31:49

    I believe the fully comprehensive answer is well explained in the PHPmyadmin documentation: https://docs.phpmyadmin.net/en/latest/ config.html#example-google-ssl

    You should follow it to configure your server connection records in config.inc.php as follows:

    // IP address of your instance
    $cfg['Servers'][$i]['host'] = '8.8.8.8';
    // Use SSL for connection
    $cfg['Servers'][$i]['ssl'] = true;
    // Client secret key
    $cfg['Servers'][$i]['ssl_key'] = '../client-key.pem';
    // Client certificate
    $cfg['Servers'][$i]['ssl_cert'] = '../client-cert.pem';
    // Server certification authority
    $cfg['Servers'][$i]['ssl_ca'] = '../server-ca.pem';
    // Disable SSL verification (see above note)
    $cfg['Servers'][$i]['ssl_verify'] = false;

    reply
    0
  • P粉399090746

    P粉3990907462023-10-24 00:31:17

    In your config.inc.php, add this line after the applicable server content:

    $cfg['Servers'][$i]['ssl']=true;

    Assuming your php and its mysql client are configured with SSL, this should work.

    reply
    0
  • Cancelreply