LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 12-15-2007, 01:23 PM   #1
jamsda
LQ Newbie
 
Registered: Apr 2006
Distribution: mostly Slack
Posts: 9

Rep: Reputation: 0
Remote MySQL connection failing


Hello,

I'm trying to get apache2.2.6 to connect to a remote mysql5.1.22 DB using php5.1.6 but getting the following error when trying to connect:

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'testDB' (13) in /var/www/html/test.php on line 3
Could not connect to the database. Error = Can't connect to MySQL server on 'testDB' (13).

If I run "php test.php" on the command-line it connects to the remote DB fine:

# php test.php

Congratulations!
<br>Successfully connected to MySQL database server.
<br>
<br>Now closing the connection...
<br>MySQL connection closed successfully as well.


I know php support is working on apache because I have a basic .php I use to verify that and is displaying php code fine. Here's a list of the php-related rpm's installed on the webserver:

# rpm -qa|grep -i php
php-common-5.1.6-3.7.fc6
php-mysql-5.1.6-3.7.fc6
php-pear-1.4.9-4
php-pdo-5.1.6-3.7.fc6
php-cli-5.1.6-3.7.fc6
php-5.1.6-3.7.fc6
php-ldap-5.1.6-3.7.fc6
php-gd-5.1.6-3.7.fc6

Here's a list of mysql-related rpm's on the webserver:

# rpm -qa|grep -i mysql
php-mysql-5.1.6-3.7.fc6
MySQL-python-1.2.1-1
mysql-5.0.27-1.fc6
mysqlclient10-3.23.58-9.2.1
perl-DBD-MySQL-3.0007-1.fc6

# rpm -qa|grep http
httpd-2.2.6-1.fc6

My php5 module is loaded:

# httpd -M (produces):
php5_module (shared)


My DB is compiled from source (didn't think that would make a difference), but here's the ver:

# mysql --version
mysql Ver 14.14 Distrib 5.1.22-rc, for redhat-linux-gnu (i686) using EditLine wrapper


Does anybody know of other ways I can troubleshoot this? I've tried cranking up the apache logs to debug, but still not seeing additional info.

Any help with this would MUCH appreciated.. I'm out of ideas


Thanks,
Jim
 
Old 12-15-2007, 07:28 PM   #2
dkm999
Member
 
Registered: Nov 2006
Location: Seattle, WA
Distribution: Fedora
Posts: 407

Rep: Reputation: 35
This note I found via a Google search may be germane, if you are running a version of Linux that has SELinux enabled:
It says, essentially, that httpd cannot open a socket to a remote machine (under PHP) unless the SELinux rules allow that; they do not allow it by default. The posting at the bottom goes on to say how to fix this.

HTH
 
Old 12-16-2007, 06:21 PM   #3
jamsda
LQ Newbie
 
Registered: Apr 2006
Distribution: mostly Slack
Posts: 9

Original Poster
Rep: Reputation: 0
Thank you!!! SELinux was the problem.. Have built these environments many times, but a first on FC6, and by default SELinux was set to enforcing.

Thanks,
Jim
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
remote connection to MySQL OpusMBE Linux - Software 2 02-28-2007 09:19 AM
MySQL Remote Connection aquatux Linux - Server 5 12-26-2006 07:12 PM
mysql remote connection error? nayyares Linux - General 2 12-21-2006 12:08 AM
Mysql Remote Connection Problems harbringer Linux - Software 5 04-14-2005 02:42 PM
Remote Connection to mysql server Graanco Linux - General 1 07-18-2003 11:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:41 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration