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>

In reply to Re: Connection to mysql database fails when using SSL by Mr. Muskrat
in thread Connection to mysql database fails when using SSL by wthebutcher

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.