Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. use DBI;
  2. use DBD::mysql;
  3. #/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();'
  4. #/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")'
  5.  
  6. my $dbh = DBI->connect("DBI:mysql:mysql:127.0.0.1:3306;mysql_read_default_file=/root/.my.cnf", undef, undef,{RaiseError => 1});
  7.  
  8. my $sql = "show databases";
  9. my $sth = $dbh->prepare($sql); # prepare the query
  10. $sth->execute(); # execute the query
  11. my @dbarray;
  12. while (@dbarray = $sth->fetchrow_array) { # retrieve one row
  13. print join(", ", @dbarray), "\n";
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement