[SOLVED] Problem to connect to remote mysql server

Support for security such as Firewalls and securing linux
Post Reply
francisko
Posts: 4
Joined: 2012/02/06 13:16:41

[SOLVED] Problem to connect to remote mysql server

Post by francisko » 2012/02/06 13:31:02

Hello,

I just install a new web server on a Linux CentOS 6. On my web site, i need to connect on a remote mysql database but i get an error "SQL error : Lost connection to MySQL server at 'reading initial communication packet', system error: 110".

I've tried the following things :
- connection on the remote database with command line.
- connection on the remote server with telnet on port 3306.
- I opened the 3306 port on iptables (input & output), i tried also with the iptables service stopped.
- I authorize httpd_can_network_connect in SELinux. I try also with SELinux disabled.

I've got a development server with the same site (and CentOS 6) and the connection with the remote database works fine. I don't understand why it doesn't work.

Could you help me please... :-?

Thx

pschaff
Retired Moderator
Posts: 18276
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America
Contact:

[SOLVED] Problem to connect to remote mysql server

Post by pschaff » 2012/02/06 23:25:18

Welcome to the CentOS fora. Please see the recommended reading for new users linked in my signature.

Please [url=http://www.centos.org/modules/newbb/viewtopic.php?topic_id=28723&forum=54]provide more information about your system[/url] by running "./getinfo.sh package" and showing us the output file, as well as[code]rpm -qa mysql\*[/code]

francisko
Posts: 4
Joined: 2012/02/06 13:16:41

Re: Problem to connect to remote mysql server

Post by francisko » 2012/02/07 06:17:46

Hello Phil,

Thx for your answer. The result of ./getinfo.sh package shows that :


Information for package problems.
[code]
== BEGIN uname -rmi ==
2.6.32-71.el6.x86_64 x86_64 x86_64
== END uname -rmi ==

== BEGIN rpm -qa \*-release\* ==
centos-release-6-0.el6.centos.5.x86_64
== END rpm -qa \*-release\* ==

== BEGIN cat /etc/redhat-release ==
CentOS Linux release 6.0 (Final)
== END cat /etc/redhat-release ==

== BEGIN getenforce ==
Disabled
== END getenforce ==

== BEGIN free -m ==
total used free shared buffers cached
Mem: 2007 1924 82 0 114 915
-/+ buffers/cache: 893 1113
Swap: 4031 1 4030
== END free -m ==

== BEGIN rpm -qa yum\* rpm-\* python | sort ==
python-2.6.5-3.el6.x86_64
rpm-libs-4.8.0-12.el6.x86_64
rpm-python-4.8.0-12.el6.x86_64
yum-3.2.27-14.el6.centos.noarch
yum-metadata-parser-1.1.2-14.1.el6.x86_64
yum-plugin-fastestmirror-1.1.26-11.el6.noarch
yum-utils-1.1.26-11.el6.noarch
== END rpm -qa yum\* rpm-\* python | sort ==

== BEGIN ls /etc/yum.repos.d ==
CentOS-Base.repo
CentOS-Debuginfo.repo
CentOS-Media.repo
== END ls /etc/yum.repos.d ==

== BEGIN cat /etc/yum.conf ==
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=16&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release

# This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
# It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
== END cat /etc/yum.conf ==

== BEGIN yum repolist all ==
Loaded plugins: fastestmirror, refresh-packagekit
Loading mirror speeds from cached hostfile
* base: mirror.ovh.net
* extras: mirror.ovh.net
* updates: mirror.ovh.net
repo id repo name status
base CentOS-6 - Base enabled: 6,294
c6-media CentOS-6 - Media disabled
centosplus CentOS-6 - Plus disabled
contrib CentOS-6 - Contrib disabled
debug CentOS-6 - Debuginfo disabled
extras CentOS-6 - Extras enabled: 4
updates CentOS-6 - Updates enabled: 326
repolist: 6,624
== END yum repolist all ==

== BEGIN egrep 'include|exclude' /etc/yum.repos.d/*.repo ==
== END egrep 'include|exclude' /etc/yum.repos.d/*.repo ==

== BEGIN sed -n -e "/^\[/h; /priority *=/{ G; s/\n/ /; s/ity=/ity = /; p }" /etc/yum.repos.d/*.repo | sort -k3n ==
== END sed -n -e "/^\[/h; /priority *=/{ G; s/\n/ /; s/ity=/ity = /; p }" /etc/yum.repos.d/*.repo | sort -k3n ==

== BEGIN rpm -qa kernel\* | sort ==
kernel-2.6.32-71.el6.x86_64
kernel-firmware-2.6.32-71.el6.noarch
== END rpm -qa kernel\* | sort ==


The MySql packages installed on my system are :

mysql-server-5.1.47-4.el6.x86_64
mysql-libs-5.1.47-4.el6.x86_64
mysql-5.1.47-4.el6.x86_64
mysql-connector-odbc-5.1.5r1144-7.el6.x86_64

_________________
Francisko

User avatar
TrevorH
Site Admin
Posts: 33218
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Problem to connect to remote mysql server

Post by TrevorH » 2012/02/07 07:43:18

You're still running CentOS 6.0 and 6.2 has been out for over a month so it's probably worth updating as one of the first things you do.

At a guess it may also be worth running

[code]
setsebool -P httpd_can_network_connect_db 1
[/code]

francisko
Posts: 4
Joined: 2012/02/06 13:16:41

Re: Problem to connect to remote mysql server

Post by francisko » 2012/02/07 08:21:34

Hello Trevor,

I tried on another virtual machine with CentOS 6.2 installed and the problem is similar.

I modify SELinux to set httpd_can_network_db = 1, but that dont change anything.

I tried also to disable SELinux and IPTables but i got the same error.

francisko
Posts: 4
Joined: 2012/02/06 13:16:41

[SOLVED] Re: Problem to connect to remote mysql server

Post by francisko » 2012/02/07 13:58:37

Hey,

The problem was not my system but the firewall on the remote server... My developpement server was authorized but not the production server.

Thanks for your help.

pschaff
Retired Moderator
Posts: 18276
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America
Contact:

Re: [SOLVED] Problem to connect to remote mysql server

Post by pschaff » 2012/02/07 18:51:23

Thanks for reporting back. Marking this thread [SOLVED] for posterity.

Post Reply