Using Perl to connect to the Mysql database website back-end database to Mysql makes it much easier to use Perl to connect to the database.
Through DBI, Perl can easily connect to the database:
#! /Bin/perl
Use DBI;
# Connect to target DB
My $ dbh = DBI-> connect ("DBI: mysql: database = eygle; host = localhost", "username", "password ", {'raiseerror' => 1 });
# Insert one row
My $ rows = $ dbh-> do ("insert into test (id, name) VALUES (1, 'eygl ')");
# Query
My $ sqr = $ dbh-> prepare ("SELECT name FROM test ");
$ Sqr-> execute ();
While (my $ ref = $ sqr-> fetchrow_hashref ()){
Print "$ ref-> {'name '}";
}
$ Dbh-> disconnect ();
Execution result:
[Root @ eygle ~] # Perl test. cgi
Eygle
In the future, many statistics can be directly written to the Mysql database through Perl, which is much easier to operate.
It seems that this migration is worthwhile :)
-The End-