Using DBI for Remote myql connection

T

Thelma Lubkin

I have only Perl on my home system. I would like to connect to a mysql
database at a system that doesn't have Perl. I thought I could do this
by installing the DBI module. But my attempt to connect apparently
failed because I didn't have DBD for mysql installed. When I tried to
install that I got error messages that seem to indicate that I need to
have mysql installed on my system before I can install that.

Obviously, I'm confused. Can I use DBI to connect to a remote mysql
database without having mysql on my system? If so, how do I install
enough stuff to do that?
thanks,
--thelma
 
J

James Willmore

I have only Perl on my home system. I would like to connect to a mysql
database at a system that doesn't have Perl. I thought I could do this
by installing the DBI module. But my attempt to connect apparently
failed because I didn't have DBD for mysql installed. When I tried to
install that I got error messages that seem to indicate that I need to
have mysql installed on my system before I can install that.

Obviously, I'm confused. Can I use DBI to connect to a remote mysql
database without having mysql on my system? If so, how do I install
enough stuff to do that?

One way to connect is to use DBD::ODBC - if the remote mysql database has
ODBC support built in. You *might* have to download the proper ODBC
driver from the MySQL site and install it on your system in order to make
this work. Trivial if you're on a Windows box - more difficult if you're
on a *nix box.

Visit http://dbi.perl.org/ for more information on how to do this. The
documentation on DBD::ODBC
(http://search.cpan.org/~jurl/DBD-ODBC-1.13/ODBC.pm) also provides useful
information on using ODBC to connect to databases.

HTH

Jim
 
S

Sherm Pendley

Thelma said:
I have only Perl on my home system. I would like to connect to a mysql
database at a system that doesn't have Perl. I thought I could do this
by installing the DBI module. But my attempt to connect apparently
failed because I didn't have DBD for mysql installed. When I tried to
install that I got error messages that seem to indicate that I need to
have mysql installed on my system before I can install that.

Obviously, I'm confused. Can I use DBI to connect to a remote mysql
database without having mysql on my system? If so, how do I install
enough stuff to do that?

DBD::mysql uses the MySQL C interface internally, so you need the client
libraries & headers to build it.

Have a look at the DBD::mysqlPP module on CPAN. I haven't used it
myself, but it looks like it might be useful. From its docs: "This
module implements network protool between server and client of MySQL,
thus you don't need external MySQL client library like libmysqlclient
for this module to work."

sherm--
 
G

Gregory Toomey

Thelma said:
I have only Perl on my home system. I would like to connect to a mysql
database at a system that doesn't have Perl. I thought I could do this
by installing the DBI module. But my attempt to connect apparently
failed because I didn't have DBD for mysql installed. When I tried to
install that I got error messages that seem to indicate that I need to
have mysql installed on my system before I can install that.

Obviously, I'm confused. Can I use DBI to connect to a remote mysql
database without having mysql on my system? If so, how do I install
enough stuff to do that?
thanks,
--thelma


Mysql supports remoet access via port 3306. I'd do this in stages

1. check to see that the mysql port 3306 is open of the remote host
telnet remotehost.com 3306

2.get a copy of the mysql client, & use it it to access the remote host

mysql --user=user_name --password=your_password --host=remotehost.com
db_name

See http://dev.mysql.com/doc/mysql/en/mysql.html


3. now that we have established connectivity, the standard mysql dbi that
comes with modern operating systems should be fine. Its very strange if you
have Perl but not dbi.

Your dbi connect styring will be
my $dbh = DBI->connect("dbi:mysql:$db:remotehost.com", "$db_user",
"$db_password");.

as per
http://perl.about.com/library/weekly/aa090803b.htm

gtoomey
 
G

gnari

Gregory Toomey said:
Thelma said:
I have only Perl on my home system. I would like to connect to a mysql
database at a system that doesn't have Perl. I thought I could do this
by installing the DBI module. But my attempt to connect apparently
failed because I didn't have DBD for mysql installed. When I tried to
install that I got error messages that seem to indicate that I need to
have mysql installed on my system before I can install that.

[snipped good advice abour confirming connectivity]
3. now that we have established connectivity, the standard mysql dbi that
comes with modern operating systems should be fine.

will still need a mysql DBD module.
the question seems to be how to install the DBD::mysql module without
installing mysql locally.

depending on what your system is, it might be easiest just to install
mysql, then the DBD module.

or, as someone suggested, use the PurePerl version of it.

gnari
 
U

Uri Guttman

g> "Gregory Toomey said:
Thelma said:
I have only Perl on my home system. I would like to connect to a mysql
database at a system that doesn't have Perl. I thought I could do this
by installing the DBI module. But my attempt to connect apparently
failed because I didn't have DBD for mysql installed. When I tried to
install that I got error messages that seem to indicate that I need to
have mysql installed on my system before I can install that.

[snipped good advice abour confirming connectivity]
3. now that we have established connectivity, the standard mysql dbi that
comes with modern operating systems should be fine.

g> will still need a mysql DBD module.
g> the question seems to be how to install the DBD::mysql module without
g> installing mysql locally.

g> depending on what your system is, it might be easiest just to install
g> mysql, then the DBD module.

AFAIK, you can install the mysql client libs without installing all of
mysql. most/all of the db's support that since clients and servers are
often different boxes. so search the mysql site for the client lib
package that suits your needs. then install the mysql DBD. you might
need to download all of mysql but even then you only need to install the
client libs.

uri
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,163
Messages
2,570,897
Members
47,436
Latest member
MaxD

Latest Threads

Top