Install the DBI and DBD-mysql modules in Perl

Source: Internet
Author: User

I. DBI Installation
Wget http://www.cpan.org/modules/by-module/DBD/DBI-1.604.tar.gz
Tar-zxvf DBI-1.604.tar.gz
CD DBI-1.604
Perl makefile. pl
Make
Make Test
Make install

Ii. DBD Installation
Yum-y intallMysql-devel
Note the MySQL environment variables. If not, add/usr/binl/MySQL to the environment variable path.
Path/usr/binl/MySQL: $ path;

Export path(Fill in the installation path of MySQL according to the actual situation)

Wget http://www.cpan.org/modules/by-module/DBD/DBD-mysql-4.006.tar.gz
Tar-zxvf DBD-mysql-4.006.tar.gz
CD DBD-mysql-4.006
Perl makefile. pl -- mysql_config =/usr/bin/mysql_config
Make
Make Test
Make install

Test connection:

#! /Usr/bin/perl
Use dBi;
$ user = "test";
$ passwd = "test ";
$ DBH = "";
$ DBH = DBI-> connect ("DBI: mysql: Database = test; host = 192.1.1.168; Port = 3306 ", $ user, $ passwd) or die "can't connect to
Database ". DBI-errstr;
$ something = $ DBH-> prepare ("select * From infobright_loaddata_status");
$ something-> execute;
while (@ RECs = $ th-> fetchrow_array) {
Print $ RECs [0]. ":". $ RECs [1]. ":". $ RECs [2]. "\ n";
}< br> $ DBH-> disconnect;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.