connecting to a Mysql via command line ok FAILs with perl 
Author Message
 connecting to a Mysql via command line ok FAILs with perl

Quote:

> use Mysql;

>         $dbh = Mysql->connect("node.com","unitdb","foo","username");
>         if ( $dbh ){
>                 print "Connected to DB\n";
>         }else{
>                 print "Connect Failed [$dbh]\n";
>         }

I don't have that module (using DBD::mysql instead), check out the
docs for a way to print out the Error String.  It will probably be
something simple like Mysql::ErrStr.  Put that string at the end of
your Connect Failed message and it should tell you exactly what the
problem is...

--
Jim Woodgate
Tivoli Systems



Tue, 20 Mar 2001 03:00:00 GMT  
 connecting to a Mysql via command line ok FAILs with perl
To mimic others, install DBI and the MySQL/mSQL DBD driver,
i used to use the Mysql package and DBI is much nicer

But, what you should do is:

$dbh = Mysql->connect("node.com","unitdb","foo","username")
    or die "Could not connect: $Mysql::db_errstr\n";

$Mysql::db_err gives you an error code i believe
and $Mysql::db_errstr gives the error string

If you are connecting to a database on the host that your perl script is on
then leave the 'host' entry to the connect procedure empty,  that is:

$dbh = Mysql->connect("","unitdb","foo","username")
    or die "Could not connect: $Mysql::db_errstr\n";

Quote:

> Hello,
> Please help..

> I can connect to my database via command line
> /usr/local/mysql/bin/mysql --password=foo unitdb

> this works ok.

> I can not attatch via a very simple perl script(see error below code):
> #!/usr/local/bin/perl

> use Mysql;

>         $dbh = Mysql->connect("node.com","unitdb","foo","username");



Tue, 20 Mar 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Connecting to mysql via perl

2. Script error:"did not produce a valid header", but runs ok from command line

3. Newbie needs help- trying to submit command-line function to perl script via web

4. DBI/CGI Problem (cmd line works, but webserver fails to connect)

5. How do you connect to a dos command line script

6. DBI:mysql Can't connect to local MySQL server

7. Help: DBD::Mysql refuses to see Mysql->connect

8. Passing Args to script via web and command line

9. Passing How Do I Send Parseable values via the Command Line

10. work on command line and not via browser?

11. outputting blank lines via the write command

12. failing to interpret * on NT command line

 

 
Powered by phpBB® Forum Software