Bug #62390 [Nab]: localhost x 127.0.0.1
| From: | rbnsjnr at gmail dot com | Date: | Mon, 25 Jun 2012 17:31:22 +0000 |
| Subject: | Bug #62390 [Nab]: localhost x 127.0.0.1 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-171521@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62390&edit=1
ID: 62390
User updated by: rbnsjnr at gmail dot com
Reported by: rbnsjnr at gmail dot com
Summary: localhost x 127.0.0.1
Status: Not a bug
Type: Bug
Package: MySQL related
Operating System: Linux-3.2.21 Debian/Wheezy
PHP Version: 5.4.4
Block user comment: N
Private report: N
New Comment:
Hello Johannes,
I believed it would be because bug with PHP 5.4.3 and 5.4.4 does not connect normally connects.
I will try to understand better about sockets, mysqli or pdo.
Anyway, thank you for your attention and support.
I wish you a great weekend and happy Saturday.
NOTE-1: I am using the google translator, it may be that there is any phrase that would not be legal
in translation.
NOTE-2: If the message [mysql_connect (): No such file or directory in / home / rubens / bd.php on
line 3
Could not connect: No such file or directory] is the treatment of missing the file / tmp /
mysql.sock is the suggestion that the message should be improved.
Previous Comments:
------------------------------------------------------------------------
[2012-06-22 11:23:28] johannes@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.
When using localhost it won't try connecting using TCP/IP but using a Unix Domain Socket. By
default it expects the socket file to be /tmp/mysql.sock. If that's not your socket location
youhave to use the --with-mysql-sock configure option or set mysql.default_socket,
mysqli.default_socket and pdo_mysql.default_socket in php.ini or use a specific socket using i.e.
mysql_connect(":/path/to/socket", "user", "pass");
You can find the socket location fromyour my.cnf file or by doing something like
<?php
mysql_connect("127.0.0.1", "root", "");
$r = mysql_query("SHOW VARIABLES LIKE 'socket'");
print_r(mysql_fetch_row($r));
?>
Please mind that using mysql_* functions from the "mysql" extension is not suggested
anymore. You should migrate to either mysqli or PDO.
------------------------------------------------------------------------
[2012-06-22 02:58:51] rbnsjnr at gmail dot com
Description:
------------
Dear (a) With PHP5.4.4 my projects do not connect more in the mysql database. I could not find
answers on the Internet.
The PHP5.4.4 is not connecting to the mysql database with the function mysql_connect () and the
parameter "localhost". When using the parameter "127.0.0.1", this function
connects without problem.
See the example below that the error does not return PHP5.4.3 and PHP5.4.4 returns an error.
Note: My PHP5.4.3 and 5.4.4 were compiled with the following parameters:
--prefix=/opt/php-5.4.3 --with-apxs2=/opt/httpd-2.4.2/bin/apxs --with-mysql
--with-pgsql=/opt/PostgreSQL/9.0/ --with-zlib --with-bz2 --with-openssl --with-kerberos
--enable-calendar --enable-ftp --enable-intl --enable-soap --enable-sockets --enable-zip
--prefix=/opt/php-5.4.4 --with-apxs2=/opt/httpd-2.2.22/bin/apxs --with-mysql
--with-pgsql=/opt/PostgreSQL/9.0/ --with-zlib --with-bz2 --with-openssl --with-kerberos
--enable-calendar --enable-ftp --enable-intl --enable-soap --enable-sockets --enable-zip
Test script:
---------------
<?php
$con = mysql_connect("localhost","u_joomlades","u_joomlades");
if (!$con)
{
die('Could not connect: ' . mysql_error());
echo "\n";
}
mysql_close($con);
echo "\n";
?>
Expected result:
----------------
Replacing the parameter "localhost" to "127.0.0.1" the PHP5.4.4 connects without
problems.
rubens@debian:~$ /opt/php-5.4.3/bin/php bd.php
rubens@debian:~$ /opt/php-5.4.4/bin/php bd.php
rubens@debian:~$
Actual result:
--------------
rubens@debian:~$ /opt/php-5.4.3/bin/php bd.php
rubens@debian:~$ /opt/php-5.4.4/bin/php bd.php
Warning: mysql_connect(): No such file or directory in /home/rubens/bd.php on line 3
Could not connect: No such file or directory
rubens@debian:~$
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62390&edit=1