#29391 [Bgs->Csd]: cannot connect to MySQL from the web server

From: Date: Wed, 28 Jul 2004 20:24:57 +0000
Subject: #29391 [Bgs->Csd]: cannot connect to MySQL from the web server
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-63699@lists.php.net to get a copy of this message
ID: 29391 User updated by: chcaron at nrcan dot gc dot ca Reported By: chcaron at nrcan dot gc dot ca -Status: Bogus +Status: Closed Bug Type: iPlanet related Operating System: Solaris 2.8 PHP Version: 4.3.8 New Comment: We just upgraded a server from 4.3.6 (using bundled MySQL) to 4.3.8 (using external MySQL 3.23.53) with iPlanet 4.1 and 6.1 and did not notice any problems. Of course, it's not exactly the same environment that produced the original bug. Previous Comments: ------------------------------------------------------------------------ [2004-07-26 20:16:29] chcaron at nrcan dot gc dot ca We are on a production server, so I can't go back to a state where PHP is not working, so here's the original output without warnings that I received from a client when he discovered it was not working (from the webserver): Warning: mysql_connect(): Can't connect to MySQL server on 'servername' (2) in /directory/where/the/script.php on line 10 Please note it did work from the command line (e.g. /usr/local/php/bin/php script.php), so MySQL is correctly configured. Also, it was working from the webserver just before we upgrade PHP from 4.3.4 to 4.3.8. I'll try to reproduce the bug on a developement server. ------------------------------------------------------------------------ [2004-07-26 18:40:48] georg@php.net How about to remove the warning suppress in mysql_connect to see what failed? ------------------------------------------------------------------------ [2004-07-26 17:40:02] chcaron at nrcan dot gc dot ca Description: ------------ PHP has been installed with "with-mysql=/usr/local/mysql". PHP 4.3.8 Mysql 4.0.15 iPlanet 6.1 It was working well with PHP 4.3.4 before we upgrade. Once we upgraded PHP to 4.3.8, we got "mysql_connect(): Can't connect to MySQL server..." when trying to open a page from the webserver. The command-line PHP was still working correctly. We recompiled PHP with "with-mysql" only (built-in MySQL) and it all started working ok. Reproduce code: --------------- <html> <body> <?php $hostname = 'hostname'; $user = 'root'; $passwd = 'password'; $database_name = 'mysql'; $error_connection = 'Cannot connect to MySQL'; $error_db = "Invalid database name ($database_name)"; if (!($connection = @ mysql_connect($hostname, $user, $passwd))) die("$error_connection"); if (!(mysql_select_db($database_name, $connection))) die("$error_db"); $query = "show tables;"; if (!($result = mysql_query ($query, $connection))) die("error"); while ($row = @ mysql_fetch_array($result)) { echo "$row[0]<br>"; } ?> </body> </html> Expected result: ---------------- The list of tables should print on the screen if ran from the webserver: columns_priv db func host tables_priv user If ran from the command line: nrn1# /usr/local/php/bin/php test_PHP_mysql.php <html> <body> columns_priv<br>db<br>func<br>host<br>tables_priv<br>user<br></body> </html> nrn1# Actual result: -------------- From the webserver: Cannot connect to MySQL From the command line: nrn1# /usr/local/php/bin/php test_PHP_mysql.php <html> <body> columns_priv<br>db<br>func<br>host<br>tables_priv<br>user<br></body> </html> nrn1# ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=29391&edit=1

« previous php.bugs (#63699) next »