Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use DBI;
- use DBD::mysql;
- #/usr/bin/perl -MDBI -MDBD::mysql -e 'print "DBI: ", DBI->VERSION , "\n"; print "DBD::mysql: ", DBD::mysql->VERSION, "\n"; my $db = DBI->connect("DBI:mysql:mysql:127.0.0.1:3306;mysql_read_default_file=/root/.my.cnf",undef,undef,{RaiseError => 1}); print "Ping!\n" if $db->ping();'
- #/usr/local/cpanel/3rdparty/bin/perl -MDBI -le 'my $db = DBI->connect("DBI:mysql:mysql:127.0.0.1:3306;mysql_read_default_file=/root/.my.cnf")'
- my $dbh = DBI->connect("DBI:mysql:mysql:127.0.0.1:3306;mysql_read_default_file=/root/.my.cnf", undef, undef,{RaiseError => 1});
- my $sql = "show databases";
- my $sth = $dbh->prepare($sql); # prepare the query
- $sth->execute(); # execute the query
- my @dbarray;
- while (@dbarray = $sth->fetchrow_array) { # retrieve one row
- print join(", ", @dbarray), "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement