Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to connect to database on another server

Status
Not open for further replies.

urhelp

Programmer
Jul 4, 2002
3
IN
Hi,

i know that if i want to connect to the mysql database the code is


$db_string = 'DBI:mysql:databasename:hostname';
$db_user = 'username';
$db_pass = 'password';

$dbh = DBI->connect($db_string, $db_user, $db_pass);



what changes i have to make if i want to connect to the mysql database on the different server than where my script is ?


urhelp
 
Before you try to use a Perl script on the client machine to connect to the MySQL server on a different host, make sure you have the MySQL client installed on the "client" machine, and make sure you can get into the mysql client on the "client" machine and connect with that client to MySQL on the "server" machine. You will be invoking the "mysql" command to bring up the MySQL client, and use the "-h"(hostname) switch to specify the hostname of the MySQL server machine.

Once you know that that works, then concentrate on getting your Perl script to connect to the remote MySQL database. For that, read the DBD::mysql perldocs - they describe connecting to the database and much more.

perldoc DBD::mysql

at a command prompt.

HTH. Hardy Merrill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top