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>
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|