blog:2013:08:12:perl_avec_mysql_et_ssl
Perl avec MySQL et SSL
Pour mémoire:
#!/usr/bin/perl -w use strict; use warnings; use DBI; { my $DBNAME = <DATABASE>; my $DBUSER = <USER>; my $DBPASS = <PASSWORD>; # database=xxx;host=xxx;mysql_ssl=1;mysql_ssl_ca_file=xxx;mysql_ssl_client_cert=xxx;mysql_ssl_client_key=xxx; my $SQL_OPTIONS = "database=$DBNAME;host=<HOST>;mysql_ssl=1;mysql_ssl_ca_file=/home/thierry/certs/mysql-ca-cert.pem;mysql_ssl_client_cert=/home/thierry/certs/mysql-client_1-cert.pem;mysql_ssl_client_key=/home/thierry/certs/mysql-client_1-key.pem;"; if ( my $dbh = DBI->connect("DBI:mysql:$SQL_OPTIONS",$DBUSER,$DBPASS) || die "Connection Error: $DBI::errstr\n" ) { my $sql = "select * from PrismNSA"; my $sth = $dbh->prepare($sql); $sth->execute() or die "SQL Error: $DBI::errstr\n"; while( my @row = $sth->fetchrow_array() ) { print "@row\n"; } $dbh->disconnect(); undef( $dbh ); } }
blog/2013/08/12/perl_avec_mysql_et_ssl.txt · Dernière modification : 2013/08/12 14:57 de thierry