I am trying to connect with mysql data base using perl but i am getting DBI error problem. I have search the web but i am not able to find any solution.
I am able to display the table using mysql
[guest@HP-UX608YY ~]$ su
[root@HP-UX608YY guest]# service mysqld start
Starting MySQL: [ OK ]
[root@HP-UX608YY guest]# mysql -u root -p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.67 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use perltest;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
mysql> select * from samples;
| id | name | phone |
| 1 | abc | 555-5555 |
| 2 | xyz | 555-6666 |
2 rows in set (0.02 sec)
My perl code is :
guest@HP-UX608YY zulfi]$ cat p1.pl
$dbh = DBI->connect('dbi-mysql:perltest:samples','root','')
or die "connection error DBI::errstr\n";
$sql ="select * from samples";
I am getting following error:
[guest@HP-UX608YY zulfi]$ perl p1.pl
Can't connect to data source 'dbi-mysql:perltest:samples' because I can't work out what driver to use (it doesn't seem to contain a 'dbi:driver:' prefix and the DBI_DRIVER env var is not set) at p1.pl line 3
Somebody plz help me.