LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 06-17-2009, 04:37 AM   #1
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 617

Rep: Reputation: 33
Lost connection to MySQL server at reading....


phpMyAdmin - Error :
2013 - Lost connection to MySQL server at 'reading initial communication packet'

I have an apache webserver running on a Fedora 10, with phpMyAdmin installed.
I have a mysql server running on another Fedora 10 system.

I have edited /etc/phpMyAdmin/config.inc.php with the IP-address of my mysql-server, my root-user and password.

When I enter http://ip-address-of-webserver/phpMyAdmin and I log in with my root - credential, I get the above error.

PhpMyAdmin.conf accepts connections from the clients connected to the LAN. But I don't think the issue is situated here.

This is the configuration of my mysql-server :
Code:
[root@database database]# hostname
database.jocan.local
I added the following to /etc/my.cnf :
Code:
bind-address=127.0.0.1
This is the output of netstat -al
Code:
tcp        0      0 localhost.localdomain:mysql *:*                         LISTEN
Do I have some kind of firewall issue on my webserver or database-server ?? Don't think I need to open port 3306 on my webserver, or do I ?

Last edited by jonaskellens; 06-17-2009 at 04:39 AM.
 
Old 06-17-2009, 05:15 AM   #2
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 18 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
Hi,

You state that you have changed your phpmyadmin config to contain the IP of your MySQL server. What IP have you put there? The localhost IP? Because your MySQL config (bind-address) makes it only listen on the localhost IP 127.0.0.1.

If you want to access mysql with phpmyadmin from another pc using the webbrowser (instead of only on the linuxbox) then you'll have to change the bind-address on the my.cnf file and change your phpmyadmin config also.

Also if you have a firewall enabled you should configure it to allow communication on port 3306 if you want to access your MySQL using another tool like MySQL Administrator.

That should do the trick.
 
Old 06-17-2009, 05:45 AM   #3
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 617

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by EricTRA View Post
You state that you have changed your phpmyadmin config to contain the IP of your MySQL server. What IP have you put there? The localhost IP? Because your MySQL config (bind-address) makes it only listen on the localhost IP 127.0.0.1.
As IP-address of my mysql-server I have put 192.168.2.4.
My webserver has IP-address 192.168.2.3

What IP-address should my MySQL-server listen to in stead of 127.0.0.1 ??
Should it listen to 192.168.2.4 ??

Quote:
Also if you have a firewall enabled you should configure it to allow communication on port 3306 if you want to access your MySQL using another tool like MySQL Administrator.
I need to open up port 3306 on my webserver too ???
 
Old 06-17-2009, 05:53 AM   #4
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 18 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
The bind-address of your MySQL server should be 192.168.2.4 in the my.cnf file if you want to connect to that IP from the webserver. Restart the MySQL daemon in order to activate it. The netstat -al command should list that mysql is listening on the correct IP and not only on localhost. localhost setting only applies if you are running MySQL and your webserver on the same server.

In your phpadminconfig you also should put that IP for the MySQL. On the webserver, if you have a firewall configured, you normally don't have to change anything since the communication from webserver to mysql is outgoing and hence not blocked. If however you also have a firewall installed on the MySQL server, than there you should make sure that connection to it on port 3306 is possible for example with telnet 192.168.2.4 3306, which will show if connection is possible. It will not give you any reasonable data or options but only will show if the port is accessible.
 
Old 06-18-2009, 04:22 AM   #5
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 617

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by EricTRA View Post
In your phpadminconfig you also should put that IP for the MySQL. On the webserver, if you have a firewall configured, you normally don't have to change anything since the communication from webserver to mysql is outgoing and hence not blocked. If however you also have a firewall installed on the MySQL server, than there you should make sure that connection to it on port 3306 is possible for example with telnet 192.168.2.4 3306, which will show if connection is possible. It will not give you any reasonable data or options but only will show if the port is accessible.
Opening port 3306 on my MySQL-server still gives me the error :
2013 - Lost Connection to MySQL-server at 'reading initial communication packet', system error 113

Shutting down the firewall on my MySQL-server makes this error disappear. Then I get :
Host '192.168.2.3' is not allowed to connect to this MySQL-server'.
So I need to edit some accept/deny-rules somewhere, like I did with my apache.

I'm a bit confused about port 3306 here...

/usr/bin/mysql_config --port returns '0'

Last edited by jonaskellens; 06-18-2009 at 04:33 AM.
 
Old 06-18-2009, 04:38 AM   #6
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 18 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
Quote:
Originally Posted by jonaskellens View Post
Opening port 3306 on my MySQL-server still gives me the error :
2013 - Lost Connection to MySQL-server at 'reading initial communication packet', system error 113

Shutting down the firewall on my MySQL-server makes this error disappear. Then I get :
Host '192.168.2.3' is not allowed to connect to this MySQL-server'.
So I need to edit some accept/deny-rules somewhere, like I did with my apache.

I'm a bit confused about port 3306 here...
Hi,

Probably you'll have to put the 'webserver' in the /etc/hosts.allow file in order to allow it to connect to the mysql server. Thing is that the webserver can connect to the mysql on the correct port but once connection is established the mysql server is going to check if the webserver is allowed access. If the webserver is not listed as allowed host then connection gets disconnected which is a normal security operation. Just changing the hosts.allow file (explanation inside the file) should do the trick if you don't have another firewall configured. If so then depending on that firewall you might also have to configure it that it should trust your webserver.

Kind regards,

Eric Van Steenbergen
 
Old 06-18-2009, 05:18 AM   #7
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 617

Original Poster
Rep: Reputation: 33
I've put the following in my /etc/hosts.allow
Code:
mysqld: 192.168.2.3
but still I get the error that '192.168.2.3 is not allowed to connect to MySQL-server.
My iptables is turned off.

When my iptables is turned on I still get the 'lost connection'-error. I have put the extra line in /etc/my.cnf :
Code:
port=3306
Code:
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 192.168.2.4:mysql           *:*                         LISTEN
 
Old 06-18-2009, 06:39 AM   #8
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 617

Original Poster
Rep: Reputation: 33
Succeeded in accessing my MySQL-server.

First off all I had opened port 3306/UDP which had to be 3306/TCP as I connect over a TCP-connection...

Second I created a new user in the mysql.user DB with the permissions needed and with the 'Host'-value being the IP-address of my webserver.

Thx for all the reply and feedback EricTRA !

Last edited by jonaskellens; 06-18-2009 at 07:03 AM.
 
Old 06-18-2009, 07:05 AM   #9
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 18 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
Quote:
Originally Posted by jonaskellens View Post
I've put the following in my /etc/hosts.allow
Code:
mysqld: 192.168.2.3
but still I get the error that '192.168.2.3 is not allowed to connect to MySQL-server.
My iptables is turned off.

When my iptables is turned on I still get the 'lost connection'-error. I have put the extra line in /etc/my.cnf :
Code:
port=3306
Code:
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 192.168.2.4:mysql           *:*                         LISTEN
Did you have to put the port = 3306 in the my.cnf? That strikes me as very strange since it's in there by default installation.

Can you telnet from the webserver to the mysql server?

Code:
telnet mysqlserverip 3306
The output would be garbled but that way you'll know that the mysql server is listening and accepting connections.
 
Old 06-18-2009, 07:07 AM   #10
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 18 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
Quote:
Originally Posted by jonaskellens View Post
Succeeded in accessing my MySQL-server.

First off all I had opened port 3306/UDP which had to be 3306/TCP as I connect over a TCP-connection...

Second I created a new user in the mysql.user DB with the permissions needed and with the 'Host'-value being the IP-address of my webserver.

Thx for all the reply and feedback EricTRA !
Yeah, great work! As always I forgot to look at the basics (Port being on UDP instead of TCP).

Glad it works. And you're welcome.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lost connection to MySQL server during query when executing 'REPAIR TABLE ... '? Ujjain Linux - Server 3 03-20-2009 09:05 AM
Error: Lost connection to MySQL server during query the expert Linux - Newbie 6 09-04-2008 12:40 PM
Lost connection to MySQL server during query figure8car Mandriva 1 12-05-2004 04:28 PM
ERROR 2013: Lost connection to MySQL server during query kicap Linux - Software 0 11-23-2004 08:30 PM
Error: lost connection to MySQL server during query patpawlowski Programming 2 01-23-2004 07:56 AM


All times are GMT -5. The time now is 10:18 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration