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

mysql_connect() on another server...

Status
Not open for further replies.

MartinCouture

Technical User
Feb 16, 2002
57
CA
$dbhost = "someserver.no-ip.com";
$dbuname = "test";
$dbpass = "test";
$dbi=@mysql_connect($dbhost, $dbuname, $dbpass);

Results: Can't connect to database.

I'm trying to have my script on a public server connect to my own mysql database (because it's too big to host on the public server) and it can't connect.

Everything works fine if $dbhost = "localhost";

-Made a remote account from MySQL Front test@% (username test from any remote IP),
-Made access through my firewall for port 3306 TCP in, and 3306 local port.

I think it must be my firewall, any brains out there for firewall setting and letting MySQL come in ??? ie: not localhost...

Thanks



-----------------
[flush]
 
It may or may not be your firewall. It could also be permissions.

When you set up the permissions for username at any address, did you issue the command as "test@'%'" or "test@%". Only the former will work correctly.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Here is the dump from MySQL Front:

SELECT * FROM mysql.user
UPDATE mysql.user SET Host='%', User='test' WHERE Host='%' AND User='test'
UPDATE mysql.db SET Host='%', User='test' WHERE Host='%' AND User='test'
UPDATE mysql.tables_priv SET Host='%', User='test' WHERE Host='%' AND User='test'
UPDATE mysql.columns_priv SET Host='%', User='test' WHERE Host='%' AND User='test'
FLUSH PRIVILEGES
SELECT * FROM mysql.user

And I get "Could not connect to Database"

I'm sure I'm not the first one to connect to a "non-localhost" mysql database...I think my firewall is setup correctly, because before it would just sit there trying to connect until it timed out, while now I get the response right away.

-----------------
[flush]
 
I took it out (@) and got a little more information:
Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (111)
(of course I put the xxx instead of my IP)

Now 111 means ?? can't seem to find an error table for MySQL...

-----------------
[flush]
 
Don't worry about the number. MySQL's text errors are pretty good.

Again, if the non-local MySQL server is on another network, verify whether the firewall on that other network will let you in. Until you cross that hurdle, you will not be able to continue.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top