473,406 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Mysql error

36
Hi all i am new to the DBI .
when i am trying to connect to mysql using perl script i am getting the following error

Can't connect to data source '$dsn' 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)
here is the way i am tryng to connect
Expand|Select|Wrap|Line Numbers
  1. use strict;
  2.  
  3. use DBI;
  4. use DBD::mysql;
  5.  
  6. my $drh = DBI->install_driver("mysql");
  7.  
  8.  my $dsn = 'DBI:mysql:my_database:localhost';
  9.  my $dbh = DBI->connect('$dsn', 'root', '12345678',);
  10.  
Jul 1 '08 #1
2 1763
eWish
971 Expert 512MB
Here is what I use for a default connection.

Expand|Select|Wrap|Line Numbers
  1. my %config_vars = (DBServerName  => 'localhost',
  2.                     DBName                => 'xxxx',
  3.                     DBUserName         => 'xxxx',
  4.                     DBPassword         => 'xxxx',
  5.                     );
  6.  
  7.  
  8. my ($dbh, $data_source);
  9. my $dataSource = 'DBI:mysql:' . $config_vars{DBName} . ':' . $config_vars{DBServerName};
  10.    $dbh = DBI->connect( $dataSource, $config_vars{DBUserName}, $config_vars{DBPassword}, {RaiseError=>1});
--Kevin
Jul 1 '08 #2
nithinpes
410 Expert 256MB
I use connect() method as below:
Expand|Select|Wrap|Line Numbers
  1. $dsn = 'my_database';
  2. $host= 'localhost';
  3. my $dbh = DBI->connect( "dbi:mysql:database=$dsn;host=$host",'root','password') or die "Can't connect to mysql database: $DBI::errstr\n";
  4.  
  5.  
Jul 1 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Kenneth Illingsworth | last post by:
--=_603E7359.5B3A569C Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I suspect that this is some kind of issue with...
0
by: Kenneth Illingsworth | last post by:
--=_603E7359.5B3A569C Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I suspect that this is some kind of issue with...
3
by: c_chen | last post by:
Hi, i am a beginner in PHP and mySQL. Whenever I try to connect my php and mysql database, i get this error.: MySQL error : access denied for myuser@localhost (Using password:yes) I have...
2
by: Elmar Grandel | last post by:
Hello, i just updated my mysql database from 4.0.x to 4.1 because i like to have the possibility to create subqueries. My problem with the new release is the following: In my running project i...
4
by: Chefry | last post by:
I'm trying to set up an off the shelf script and keep getting an error. My host set up the mysql on my site and I changed the variables I had to in the settings.php file but I keep getting the...
2
by: mmoor | last post by:
mysql_query("SELECT name, street, url, extra1, extra2, i0+i1+i2+i3+i4 AS incoming, o0+o1+o2+o3 AS rent, s0+s1+s2 AS wohnung FROM amigo WHERE top='1' AND status='1' AND ($row) ORDER BY $row"); ...
6
by: Justin.Voelker | last post by:
Can anyone clue me on on how to have my html page continue rendering past a MySQL error? If you visit www.Base2WebDesign.com, click login, type in anything for a username and password, then view...
1
by: Nabarun | last post by:
I have discovered a new thing as a solution for MySql error 10061 (error 2003) where if port 3306 is busy then service cannot run message comes The solution I found is go to mysql/bin type...
3
by: jaymzlx | last post by:
My old problem is solved, but im running into a new error. I figured I would start a new topic, sorry if this was incorrect to do. mysql error: You have an error in your SQL syntax; check the...
4
by: ebflute | last post by:
What is wrong with my SQL statement? I moved this application from a PHP4 server to a PHP5 server with a higher version of MySQL. It was working on the old server but now I am getting an error in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.