Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Connection to mysql database fails when using SSL

by Mr. Muskrat (Canon)
on Aug 01, 2017 at 18:17 UTC ( [id://1196476]=note: print w/replies, xml ) Need Help??


in reply to Connection to mysql database fails when using SSL

Try this out and see it works better. The connect method is not documented to accept a DSN in that format.

#!/usr/bin/perl use strict; use warnings; use v5.10; use DBI; say "Perl MySQL Connect Demo"; my $db = 'db'; # or whatever it really is my $server = 'server'; # ditto my $dsn = "DBI:mysql:database=$db;host=$server"; my $username = "user"; my $password = 'password'; my $dbh = DBI->connect($dsn,$username,$password);

See also DBD::mysql Class Methods for the full documentation on connect.

Update: You may also need to add in the port.

Update 2: You may need to set some MySQL specific variables in order to get a secure connection working.

... my $port = 12345; # whatever is should be my $dsn = "DBI:mysql:database=$db;host=$server;port=$port; mysql_ssl=1; mysql_ssl_client_key=/var/lib/ssl/client-key.pem; mysql_ssl_client_cert=/var/lib/ssl/client-cert.pem; mysql_ssl_ca_file=/var/lib/ssl/cacert.pem"; # Your paths may vary... ...
<code>

Replies are listed 'Best First'.
Re^2: Connection to mysql database fails when using SSL
by wthebutcher (Initiate) on Aug 03, 2017 at 13:39 UTC
    Hi Mr. Muskrat, thank you for your response...it's been really helpful trying to debug what's going on. The thing is...I don't even want to use SSL to connect, as the connection will manage data that is neither relevant nor important (it's one of the tools percona provides to perform some checks over the data, but I tracked the issue to the connection itself rather than the tool, as I was able to reproduce the error creating that simple connection script). I tried specifying mysql_ssl=0 at the dsn, with no luck. I can connect to the server using mysql client without SSL, but couldn't get it to work with perl. Perl version is v5.22.1 built for x86_64-linux-gnu-thread-multi, and we first started having this kind of issues when we moved from Ubuntu 12.04 to Ubunt 16.04 Any Ideas?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1196476]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-25 15:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found