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

Trouble Connecting to Remote MySQL Databse

Status
Not open for further replies.

lonelycastle

Programmer
Nov 9, 2008
1
US
I've been struggling with this problem for a few weeks. I need to connect to a mysql database on another (remote) server. I've set up the user and granted all permissions, etc. and I can connect to it from some of my other websites, but not from the one I'm working on.

Here's how I granted my permissions:
Code:
GRANT ALL ON *.* TO 'user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL ON *.* TO 'user'@'%' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

And here's how I'm connecting:
Code:
mysql_connect('66.246.229.94','username','password');

As I've said I've been able to get this to work on some websites, but not the one's I actually need it for. Here's the mysql_error() I get:
Code:
Can't connect to MySQL server on '66.246.229.94' (111)

Here's the mysql phpinfo() for said site:
Code:
MySQL Support	enabled
Active Persistent Links 	0
Active Links 	0
Client API version 	3.23.49
MYSQL_MODULE_TYPE 	builtin
MYSQL_SOCKET 	/var/lib/mysql/mysql.sock
MYSQL_INCLUDE 	no value
MYSQL_LIBS 	no value

Directive	Local Value	Master Value
mysql.allow_persistent	On	On
mysql.connect_timeout	60	60
mysql.default_host	no value	no value
mysql.default_password	no value	no value
mysql.default_port	no value	no value
mysql.default_socket	no value	no value
mysql.default_user	no value	no value
mysql.max_links	Unlimited	Unlimited
mysql.max_persistent	Unlimited	Unlimited
mysql.trace_mode	Off	Off


The "MYSQL_MODULE_TYPE" and "Client API version" are the only thing I can think of which might help me solve the problem.

Any thoughs?
 
Can you use the mysql command-line client from the remote server? Is the remote server outside the local network? If so, could this be a firewall problem?

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
I'd bet Don is right, your firewall is probably blocking access to that IP, or at least to port 3306 (unless you changed the default port). Or MySQL is not running as tcp/ip and is using a socket only instead.

Try pinging the server.

Try also checking to see if the server is running MySQL as a tcp server. On the server, run...
ps -eaf |grep 3306

Should return something like...
/usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top