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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mySQL Remote Server Connection

Status
Not open for further replies.

kennygadams

Programmer
Jan 2, 2005
94
0
0
US
I'm trying to make a mySQL connection from server-1 to server-2 but it wont let me.

Is this code wrong?
Code:
if($dbh = DBI->connect("DBI:mysql:name_of_database:12.34.56.78", "username", "password")){
	$connected = 'y';
	}
else{
	$connected = 'n';
	}

Thanks,

Kenny G. Adams
 
my $dsn = 'DBI:mysql:dbname=testdbname;host=testhost';
my $dblogin = 'testuser';
my $dbpass = 'testpass';
my $dbh = DBI->connect($dsn,$dblogin,$dbpass) or die "Can't connect to DB:$!\n";

This is from a script I happen to have up tha tI now works.


Travis



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
are you sure it's listenting on the correct port, and that no firewall is blocking access?

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Thanks for helping.

I ran the following on the command line to give my remote server privileges for accessing the mysql database.

Login to mysql as the root user
Code:
mysql -u root -p
Feedback from server: Enter password:

Enter your root user password:
Code:
XXXXXXXXX
Feedback from server: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 12859658 to server version: 5.0.22

Enter the following to give your remote server privileges to access the database:
Code:
GRANT ALL ON database_name_goes_here.* TO username_goes_here@ip_goes_here IDENTIFIED BY 'password_goes_here';
Feedback from server: Query OK, 0 rows affected (0.00 sec)

Best regards,

Kenny G. Adams
- Blog about Boneheads
 
so you're sorted now?
if not amend travs69's script for your own details, and see what happens ...

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
The windows mysql GUI is pretty slick and easy to use if you haven't tried it. I use it to administrate mysql DB's on a few other OSs (redhat, centos, solaris).

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top