Connecting MySql throug Perl Script ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Connecting MySql throug Perl Script ?
# 1  
Old 01-17-2006
Bug Connecting MySql throug Perl Script ?

Dear Friends,

I am tryin to connect to the myql through perl scrip. I have already installed mysql and DBI modules to my Perl.

There versions are as follows,

DBD-mysql [2.1026] MySQL driver for the Perl5 Database
DBI [1.34] Database independent interface for

It gives erroe when I tried to connected to the sql. The error as follows,

Mysql connect('database=pps_cdr;host=localhost','root',...) failed: Client does not support authentication protocol requested by server; consider upgrading MySQL client at db_test.pl line 7

My perl script as follows,

use Mysql;
my $DBHOST = "localhost";
my $DBNAME = "pps_cdr";
my $DBUSER = "root";
my $DBPASS = "mahesh";

$DB = Mysql->connect($DBHOST, $DBNAME, $DBUSER, $DBPASS);

Can somebody tell me how can I avoid this error.

Thanks,
Mahesh Fernando
# 2  
Old 01-17-2006
Try this, i'm running number of perl scripts with mysql, i never had any problems...


use DBI;

#Specify the MySQL server
my $host = "localhost";

my $username = "root";
my $password = "mahesh";

my $db_name = "pps_cdr";

my $dsn = "DBI:mysql:database=$db_name;host=$host";

$dbh = DBI->connect($dsn, $username, $password);

$self->dbh = $dbh;


I have learned mysql perl programming by searching google, you can also find lot of stuff in google...
# 3  
Old 01-17-2006
One possibility: the pre-4.1 client and 4.1+ server problem. In MySQL 4.1 the format of authentication token has changed to use garbled passwords of greater length (and thus greater cryptographic strength). MySQL clients 3.x/4.0 only support the old, shorter password hash, then authentication will fail with 4.1+ servers. If your server is 4.1 or later, it is quite likely this is the problem.

Your DBD::mysql is a compiled Perl module which requires a MySQL client library on compilation. That client version shall become the version of the client used by the DBD::mysql module. Try to reinstall your DBD::mysql to use a newer client library and see if that works.

Another way to get around this: enable the "old_passwords" option at the server, reinitialize *ALL* passwords at the server then the passwords should now be stored in old, shorter format (you should check the mysql.user table to make sure).
# 4  
Old 01-17-2006
Quote:
Originally Posted by maheshsri
use Mysql;
And I have forgotten. Don't use the Mysql module. Use DBI with DBD::mysql instead, as you said you have installed it in your previous post. Mysql and DBD::mysql are two separate modules. DBD::mysql supersedes Mysql.
# 5  
Old 01-18-2006
Hi Guys,

Thanks for the help.
After updating my perl module it is working fine.

Thaks,
mahesh Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Online insert MySQL rows by perl-script

Hello, Met a problem when I tried to insert rows to MySQL database from an old book that fits my learning level (MySQL and Perl for the Web, by Paul DuBois, 2001). First, under mysql console I created a database: webdb and the table: todo. Then I draft the perl-cgi script to have online page.... (0 Replies)
Discussion started by: yifangt
0 Replies

2. Programming

Help with mySQL database by perl script

Hello; I was trying to set up a mysql database using following script, but never went through. The code seems fine without any syntax error as I tested it: perl -c Brapa0101-db.pl Brapa0101-db.pl syntax OKHowever, whenever I run it, an error message was tossed out: DBD::mysql::st execute... (7 Replies)
Discussion started by: yifangt
7 Replies

3. Shell Programming and Scripting

Help with perl mysql backup script

Hi, im trying to make a script that backups mysql databases but apparently I am having trouble with the variables, or simply something I am missing. Would appreciate any help, here is the script #!/usr/bin/perl -w use strict; require File::Spec; #VARIABLES my $databasename =... (4 Replies)
Discussion started by: Fireline
4 Replies

4. Shell Programming and Scripting

how to print out data from mysql table in perl script

I'm having trouble with this code. if i do .\read.pl -u user it prints out 2010-12-20 12:00:00 host1 <cmd>a 2010-12-20 12:00:01 host1 <cmd> <execute> 2010-12-20 12:00:02 host1 <cmd>b 2010-12-20 12:00:03 host1 <cmd>c however, if i enter .\read.pl -h host1 it should... (3 Replies)
Discussion started by: kpddong
3 Replies

5. UNIX and Linux Applications

Error while connecting to MySQl Server 5.1.34 on UNIX platform.

Hi, I have MySQL 5.1.34 installed on Solaris and Linux machine. MySQl installed Solaris Machine - A.A.A.A Remote Machine - B.B.B.B I have user in mysql.user as below: | user | password | host |... (2 Replies)
Discussion started by: amit_27
2 Replies

6. Shell Programming and Scripting

Find shell process pid launched throug `at`.

Hi. I was testing some staff and wrote simple script, which only writes date to log every 15 seconds. Like that #1.sh while true;do echo `date` >> 1.log sleep 15 done And than i ran this process with `at -s -f 1.sh now`. And now it is running and i don't know how to catch it. I tryed... (1 Reply)
Discussion started by: kukuruku
1 Replies

7. Shell Programming and Scripting

perl+CGI+mysql !!!!!!!

hi expert, I am totally new to perl CGI coding. And stop by below issue: 1> i have a script names conn.pl, which can connect to mysql and get the information of table user(id,name) 2> i copied above code into one CGI web page named user.cgi 3> when i view user.cgi in web browser, it toldme... (3 Replies)
Discussion started by: summer_cherry
3 Replies

8. Shell Programming and Scripting

connecting to sqlserver from perl

Hi, I am doing a migration of Oracle database to SQLSERVER 2005.Mostly my application code is perl scripts and i want to modify the scripts so as to connect to SQLSERVER. What all would be the changes i have to make for just establishing a connection from Perl script to SQLSERVER... (3 Replies)
Discussion started by: DILEEP410
3 Replies

9. Shell Programming and Scripting

error connecting database from perl

Hi, While i am trying to connect to Oracle database from Perl using DBI module,am getting the error as follows : Can't load '/usr/local/fuseperl-modules/lib/i586-linux-thread-multi/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: libwtc9.so: cannot open shared object file: No such file... (4 Replies)
Discussion started by: DILEEP410
4 Replies
Login or Register to Ask a Question