php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34188 mysql_connect can connect via localhost but *not* via TCP/IP
Submitted: 2005-08-18 18:40 UTC Modified: 2005-08-21 18:08 UTC
From: ken dot senior at nrl dot navy dot mil Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 5.0.4 OS: Linux 2.6.11-1.1369_FC4
Private report: No CVE-ID: None
 [2005-08-18 18:40 UTC] ken dot senior at nrl dot navy dot mil
Description:
------------
Just installed FC4 OS, Apache, PHP, MySQL, and php-mysql (all via yum) and discovered a strange bug when using PHP to connect to MySQL.  The only connection which will work is to a local instance of MySQL via a socket, i.e., localhost setting.  However, TCP/IP connections, both local as well as to other remote MySQL servers, result in the PHP error:

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on '192.168.0.4' (13) in /var/www/html/IGStime/index.php on line 720
could't connect to MySQL server

Usually, the problem is just the opposite, that is being able to connect via TCP/IP but not sockets.  Does anyone have a clue about this?

Ken Senior


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-18 18:47 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Give connect privileges to your user.
 [2005-08-18 18:50 UTC] ken dot senior at nrl dot navy dot mil
Since the mysql clients can connect (i.e., outside of PHP) via both sockets and via TCP/IP methods, how can it be anything but PHP/php-mysql?
 [2005-08-21 17:54 UTC] ken dot senior at nrl dot navy dot mil
NOTE:  All client scripts work outside PHP so this must be a problem with PHP/php-mysql.
 [2005-08-21 18:02 UTC] rasmus@php.net
This is still not a support forum.  Millions of sites out there are connecting PHP to MySQL.  You have some problem unique to your server which you need to work through.  If you do eventually discover an actual bug in PHP related to this and you can provide some sort of information other than, "it doesn't work, fix it!" then let us know.  From what you have given us we couldn't possibly help you solve this without a dozen back and forth questions trying to narrow down the cause.  That's simply not what the bug database is for, sorry.  Try one of the mailing lists at http://www.php.net/mailing-lists.php
 [2005-08-21 18:08 UTC] rasmus@php.net
By the way, my guess would be an selinux problem.  So that gives you a starting point to start asking about.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 21 08:00:02 2025 UTC