3
votes

I have two Debian boxes:

  1. used apt-get to install mysql-server mysql-client phpmyadmin
  2. used apt-get to install apache2 apache2-mod-php5

I'm trying to connect to the MySQL server using the Apache box but I get this error from PHP:

Lost connection to MySQL server at 'reading initial communication packet', system error: 113

I can connect up to MySQL fine using a Windows-based client on the same network. This makes me wonder about how the Apache2/PHP is setup.

Additional reading about error 113 makes me wonder about hostnames and such. my.cnf on MySQL box is set to bind-address = 192.168.1.202, and PHP is trying to connect to 192.168.1.202.

Any and all help greatly appreciated! I'm not an evil genius by a long shot and this is my first time trying to use solely aptitude to set this up. I bet it's something silly I forgot.

2
can you telnet from the PHP server to mysql using port 3306? telnet 192.168.1.202 3306sreimer
I had this happen yesterday... try commenting out all bind addresses.Peter
@sremier from Apache2 box I can telnet to the MySQL server using your command. I'm attempting to login as root, which of course is denied as it's set to only allow for localhost. It shows an error similar to 'host not allowed to connect' yet the PHP connect error is still talking about an prematurely terminated connection. Bummer.user549167
@Peter thank you for the tip. I changed this out (I assume it's now listening everywhere it can) but the Apache2 box won't show me a useful error. I assume it would say something about host not allowed to connect? Right?user549167
It will not say host not allowed.. You would get something like the first error you encountered, or something similar to a authentication failure. If your setting up Apache and MySQL on two different servers in the same network. You should be able to set the bind address to the local network address of the MySQL Box, then add a user account just for the Apache box to connect via that address.Peter

2 Answers

2
votes

I'm using Ubuntu 11.04

I logged in as root and ran

cd /etc/mysql
nano my.cnf

Then I found bind-address = 127.0.0.1 and added a # before it so it's looks like #bind-address = 127.0.0.1

Than I ran /etc/init.d/mysql restart to restart MySQL. Then it started working.

Hope this helps. I know Debian and Ubuntu are about the same when doing stuff.

0
votes

Make sure the IP you are trying to connect to is correct and not firewalled