LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-27-2009, 10:56 AM   #1
manoj1007
LQ Newbie
 
Registered: Aug 2009
Posts: 3

Rep: Reputation: 0
Unhappy Using Perl to connect to MySQL using webmin


Hi,
I wrote a test script in Webmin to see if I could connect to my mysql database

When I tried to run the script on Webmin, I got the following error


Error - Perl execution failed

install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains: /usr/local/webmin /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 . /usr/local/webmin/ ..) at (eval 57) line 3.
Perhaps the DBD::mysql perl module hasn't been fully installed,
or perhaps the capitalisation of 'mysql' isn't right.
Available drivers: DBM, ExampleP, File, Gofer, Proxy, Sponge.


The following is my script in webmin

use DBI;
&ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);


$db_handle=DBI->connect("dbi:mysql:database=mysql;host=xxxx;user=root;password=xxxx")
or die "Could not connect to database: $DBI::errstr\n";


I did install the DBI module from CPAN (DBI-1.609) and the command "make install" as part of the last command to install gave the following result, which doesn't show any problems installing

Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Writing /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBI/.packlist
Appending installation info to /usr/lib/perl5/5.8.8/i386-linux-thread-multi/perllocal.pod

Can someone help me please? http://http.cdnlayer.com/lq/images/q...s_lq/icon9.gif

Thanks,

MJ
 
Old 08-27-2009, 01:06 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
And what about
Quote:
/usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 . /usr/local/webmin/ ..) at (eval 57) line 3.
Perhaps the DBD::mysql perl module hasn't been fully installed,
or perhaps the capitalisation of 'mysql' isn't right.
Available drivers: DBM, ExampleP, File, Gofer, Proxy, Sponge.
?


Cheers,
Tink
 
Old 08-31-2009, 04:46 PM   #3
manoj1007
LQ Newbie
 
Registered: Aug 2009
Posts: 3

Original Poster
Rep: Reputation: 0
DBD install

Hi Tinkster,
Thanks for your tip, I tried installing DBD and got the following error on make test

PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00base....................ok
t/10connect.................skipped
all skipped: ERROR: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) Can't continue test

I initially had an error where it could not find the file libapreq2.so.which I found was in the wrong location, so I created a symbolic link to the file.

I went ahead with the install and did a make install, but now the script which tries to connect with the database gives the following error.

HTTP/1.0 500 Perl execution failed Server: MiniServ/0.01 Date: Mon, 31 Aug 2009 21:29:52 GMT Content-type: text/html Connection: close
Error - Perl execution failed

Couldn't connect to database: Access denied for user 'root'@'192.168.1.22' (using password: YES)

Any thoughts
 
Old 08-31-2009, 05:18 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Sorry mate .. I don't do MySQL as a matter of principle
I'm attached to my data...


Cheers,
Tink
 
Old 08-31-2009, 06:02 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Show your Perl program, and keep in mind that the Linux root user is not(!) the same as the MySQL root user (basically the DBA acct).
 
Old 09-01-2009, 09:13 AM   #6
manoj1007
LQ Newbie
 
Registered: Aug 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Hi Chris,
Thanks for your help, but I am all set. It was a permission issue and once I gave the root user proper privileges, my script worked

Last edited by manoj1007; 09-02-2009 at 12:04 PM.
 
Old 09-01-2009, 11:32 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
I'd start by just running this prog at the cli; easier to debug.
A couple of things look odd to me:

Code:
&ui_print_header(undef, $text{'index_title'}, undef, "intro", 1, 1, 0,
&help_search_link("iptables", "man", "doc"), undef, undef,desc);
Taken literally, that's one long line of code, with a nested call to sub help_search_link() in the call to ui_print_header().
I'm not convinced that's right.
Using '&' as a prefix when calling a sub is deprecated for Perl 5.x. Strictly speaking it means calling the sub by passing a reference to it, instead of calling it directly. I doubt you mean that.

I'd try debugging by commenting out everything after
Code:
print "Hello";
which should probably be
Code:
print "Hello\n";
In any case, you have unmatched table tags http://www.w3schools.com/tags/tag_td.asp and you're not using closing tags ie </td> </tr>

Also, amend the start of your prog to be
Code:
#!/usr/bin/perl -w
use strict;
See also
http://perldoc.perl.org/
http://www.perlmonks.org/?node=Tutorials
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. NoviceW Linux - Networking 17 09-17-2014 02:13 PM
Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL serve vinnyband Linux - Software 3 10-30-2008 02:53 PM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. SpellChainz Linux - Newbie 1 06-23-2007 03:35 PM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. Dannux Linux - Software 3 03-24-2006 08:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration