Forum Moderators: open

Message Too Old, No Replies

Connect to WAMP from Remote Server

         

almo136

1:14 am on Oct 15, 2009 (gmt 0)

10+ Year Member



Hi,

I have a mysql database on my local installation of WAMP. To access this database I would use something like this:

$link = mysql_connect('localhost', 'root', 'root');

If I wanted to access this same database from a remote server what would I use? Do I just replace localhost with the ip address of my machine?

Thanks!

phranque

5:05 am on Oct 16, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



you will probably want to find The Error Log [dev.mysql.com] before you start troubleshooting.

this is probably a good place to start:
MySQL :: MySQL 5.1 Reference Manual :: B.1.2.2 Can't connect to [local] MySQL server:
[dev.mysql.com...]

you will probably have to GRANT [dev.mysql.com] some privileges to remote users.

almo136

11:17 pm on Oct 19, 2009 (gmt 0)

10+ Year Member



I am having some issues trying to make this remote connection. Here is what I've done so far:

1. Created a user in phpmyadmin and granted them all global privleges and from any host.
2. Used the following script to try and connect to the database from my remote server:

<?php
$dbServer1='99.99.999.999';

// username and password to log onto db server
$dbUser1='username';
$dbPass1='password';

// name of database
$dbName1='databasename';

$link = mysql_connect("$dbServer1", "$dbUser1", "$dbPass1") or die("Could not connect");
print "Connected successfully to your_db_name1<br>";
mysql_select_db("$dbName1") or die("Could not select database your_db_name1");
print "Database your_db_name1 selected successfully<br><br><br>";

// close connection
mysql_close($link);

?>

I added the ip address of my local machine and the username and password of the user I created in phpmyadmin to the appropriate places.

When I run the script I get the following error:

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on '99.99.999.999' (4) in /home/toomany2/public_html/testdbconnection.php on line 29
Could not connect

When testing I turned off my firewall and plugged my computer directly into the modem.

If I change the server to localhost and run it locally it connects no problem.

The remote machine is running OS X if that makes any difference.

Have I missed something to allow the remote connection?

Thanks

phranque

2:02 pm on Oct 20, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



have you reloaded the grant tables?
(not sure how to do that using phpmyadmin)

if you can, look at the 'user' and 'host' tables in the 'mysql' database.
that might give you hints.