Re: [PHP-DB] PHP5-MySQL Not Connecting Through Socket
how about change bind-address = 127.0.0.1 http://127.0.0.1/ to bind-address = your.real.ip.address may be it works. I got the same trouble a few days ago, but I forgot how I fixed it .. :-( some changes in my.cnf On 8/30/05, Evan J [EMAIL PROTECTED] wrote: Hi, I am running PHP 5.0.4 and MySQL 4.1.3a. (+Apache 2.0.54) When I run a PHP script that attempts to connect to MySQL I get the following error: Database ERROR:Can't connect to local MySQL server through socket '/usr/local/mysql/tmp/mysql.sock' (13) I have placed my socket file on such location when I was configuring MySQL and PHP was compiled with --with-mysql-sock=/usr/local/mysql/tmp/mysql.sock (and even with /usr/local/mysql/tmp). I even edited my php.ini (/usr/local/php/lib/php.ini, I have installed PHP with --prefix=/usr/local/php) and modified variable: mysql.default_socket = /usr/local/mysql/tmp/mysql.sock It still refuses to connect through the socket! I have also run a simple mysql_connect() script to see if the intended script was the culprit but again, it could not connect to MySQL. phpinfo() indicates the following: MYSQL_SOCKET /usr/local/mysql/tmp/mysql.sock MYSQL_INCLUDE -I/usr/local/mysql/include/mysql MYSQL_LIBS -L/usr/local/mysql/lib/mysql -lmysqlclient And for directives: mysql.default_port no value no value mysql.default_socket /usr/local/mysql/tmp/mysql.sock /usr/local/mysql/tmp/mysql.sock That being said, I CAN connect to the database via 127.0.0.1http://127.0.0.1 through TCP/IP but not through Unix Socket file. The permissions on mysql.sock is: ls -la /usr/local/mysql/tmp/ total 0 drwxrwx--- 2 mysql mysql 80 2005-08-24 22:09 ./ drwxr-xr-x 13 root mysql 328 2005-08-22 20:03 ../ srwxrwxrwx 1 mysql mysql 0 2005-08-24 22:09 mysql.sock= Again, I can connect to DB through other programs (non-php) or via commandline and even TCP but not through Unix socket file!! Any ideas? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- From : Fen lu
Re: [PHP-DB] PHP5-MySQL Not Connecting Through Socket
Ok, someone mentioned that I did not have an appropriate permission to access mysql.sock directory. Guess what? He was right on the spot. So for whomever who reads this, the solution proposed is to `chmod 755 /usr/local/mysql/tmp' Thanks to that individual who assisted me on this. On 9/2/05, Fen Lu [EMAIL PROTECTED] wrote: how about change bind-address = 127.0.0.1 to bind-address = your.real.ip.address may be it works. I got the same trouble a few days ago, but I forgot how I fixed it .. :-( some changes in my.cnf On 8/30/05, Evan J [EMAIL PROTECTED] wrote: Hi, I am running PHP 5.0.4 and MySQL 4.1.3a. (+Apache 2.0.54) When I run a PHP script that attempts to connect to MySQL I get the following error: Database ERROR:Can't connect to local MySQL server through socket '/usr/local/mysql/tmp/mysql.sock' (13) I have placed my socket file on such location when I was configuring MySQL and PHP was compiled with --with-mysql-sock=/usr/local/mysql/tmp/mysql.sock (and even with /usr/local/mysql/tmp). I even edited my php.ini (/usr/local/php/lib/php.ini, I have installed PHP with --prefix=/usr/local/php) and modified variable: mysql.default_socket = /usr/local/mysql/tmp/mysql.sock It still refuses to connect through the socket! I have also run a simple mysql_connect() script to see if the intended script was the culprit but again, it could not connect to MySQL. phpinfo() indicates the following: MYSQL_SOCKET/usr/local/mysql/tmp/mysql.sock MYSQL_INCLUDE -I/usr/local/mysql/include/mysql MYSQL_LIBS -L/usr/local/mysql/lib/mysql -lmysqlclient And for directives: mysql.default_port no valueno value mysql.default_socket/usr/local/mysql/tmp/mysql.sock /usr/local/mysql/tmp/mysql.sock That being said, I CAN connect to the database via 127.0.0.1 through TCP/IP but not through Unix Socket file. The permissions on mysql.sock is: ls -la /usr/local/mysql/tmp/ total 0 drwxrwx--- 2 mysql mysql 80 2005-08-24 22:09 ./ drwxr-xr-x 13 root mysql 328 2005-08-22 20:03 ../ srwxrwxrwx 1 mysql mysql 0 2005-08-24 22:09 mysql.sock= Again, I can connect to DB through other programs (non-php) or via commandline and even TCP but not through Unix socket file!! Any ideas? -- PHP Database Mailing List ( http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- From : Fen lu -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PHP5-MySQL Not Connecting Through Socket
try #: mysqld for test? I think your mysql is not running~... I met this problem last night...hehe... On 9/2/05, Evan J [EMAIL PROTECTED] wrote: Ok, someone mentioned that I did not have an appropriate permission to access mysql.sock directory. Guess what? He was right on the spot. So for whomever who reads this, the solution proposed is to `chmod 755 /usr/local/mysql/tmp' Thanks to that individual who assisted me on this. On 9/2/05, Fen Lu [EMAIL PROTECTED] wrote: how about change bind-address = 127.0.0.1 http://127.0.0.1 to bind-address = your.real.ip.address may be it works. I got the same trouble a few days ago, but I forgot how I fixed it .. :-( some changes in my.cnf On 8/30/05, Evan J [EMAIL PROTECTED] wrote: Hi, I am running PHP 5.0.4 and MySQL 4.1.3a. (+Apache 2.0.54) When I run a PHP script that attempts to connect to MySQL I get the following error: Database ERROR:Can't connect to local MySQL server through socket '/usr/local/mysql/tmp/mysql.sock' (13) I have placed my socket file on such location when I was configuring MySQL and PHP was compiled with --with-mysql-sock=/usr/local/mysql/tmp/mysql.sock (and even with /usr/local/mysql/tmp). I even edited my php.ini (/usr/local/php/lib/php.ini, I have installed PHP with --prefix=/usr/local/php) and modified variable: mysql.default_socket = /usr/local/mysql/tmp/mysql.sock It still refuses to connect through the socket! I have also run a simple mysql_connect() script to see if the intended script was the culprit but again, it could not connect to MySQL. phpinfo() indicates the following: MYSQL_SOCKET /usr/local/mysql/tmp/mysql.sock MYSQL_INCLUDE -I/usr/local/mysql/include/mysql MYSQL_LIBS -L/usr/local/mysql/lib/mysql -lmysqlclient And for directives: mysql.default_port no value no value mysql.default_socket /usr/local/mysql/tmp/mysql.sock /usr/local/mysql/tmp/mysql.sock That being said, I CAN connect to the database via 127.0.0.1http://127.0.0.1 through TCP/IP but not through Unix Socket file. The permissions on mysql.sock is: ls -la /usr/local/mysql/tmp/ total 0 drwxrwx--- 2 mysql mysql 80 2005-08-24 22:09 ./ drwxr-xr-x 13 root mysql 328 2005-08-22 20:03 ../ srwxrwxrwx 1 mysql mysql 0 2005-08-24 22:09 mysql.sock= Again, I can connect to DB through other programs (non-php) or via commandline and even TCP but not through Unix socket file!! Any ideas? -- PHP Database Mailing List ( http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- From : Fen lu -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- From : Fen lu
Re: [PHP-DB] PHP5-MySQL Not Connecting Through Socket
No Fen Lu, as I said in my first post, MySQL runs just fine and for some strange reason all other applications can connect through unix socket to the database except PHP scripts. But I solved the problem but chmod'ing the directory of the socket file rather the socket file itself. It had slipped through my eyes; now everything works as it's expected [CASE CLOSED]. On 9/2/05, Fen Lu [EMAIL PROTECTED] wrote: try #: mysqld for test? I think your mysql is not running~... I met this problem last night...hehe... On 9/2/05, Evan J [EMAIL PROTECTED] wrote: Ok, someone mentioned that I did not have an appropriate permission to access mysql.sock directory. Guess what? He was right on the spot. So for whomever who reads this, the solution proposed is to `chmod 755 /usr/local/mysql/tmp' Thanks to that individual who assisted me on this. On 9/2/05, Fen Lu [EMAIL PROTECTED] wrote: how about change bind-address = 127.0.0.1 to bind-address = your.real.ip.address may be it works. I got the same trouble a few days ago, but I forgot how I fixed it .. :-( some changes in my.cnf On 8/30/05, Evan J [EMAIL PROTECTED] wrote: Hi, I am running PHP 5.0.4 and MySQL 4.1.3a. (+Apache 2.0.54) When I run a PHP script that attempts to connect to MySQL I get the following error: Database ERROR:Can't connect to local MySQL server through socket '/usr/local/mysql/tmp/mysql.sock' (13) I have placed my socket file on such location when I was configuring MySQL and PHP was compiled with --with-mysql-sock=/usr/local/mysql/tmp/mysql.sock (and even with /usr/local/mysql/tmp). I even edited my php.ini (/usr/local/php/lib/php.ini, I have installed PHP with --prefix=/usr/local/php) and modified variable: mysql.default_socket = /usr/local/mysql/tmp/mysql.sock It still refuses to connect through the socket! I have also run a simple mysql_connect() script to see if the intended script was the culprit but again, it could not connect to MySQL. phpinfo() indicates the following: MYSQL_SOCKET/usr/local/mysql/tmp/mysql.sock MYSQL_INCLUDE -I/usr/local/mysql/include/mysql MYSQL_LIBS -L/usr/local/mysql/lib/mysql -lmysqlclient And for directives: mysql.default_port no valueno value mysql.default_socket /usr/local/mysql/tmp/mysql.sock /usr/local/mysql/tmp/mysql.sock That being said, I CAN connect to the database via 127.0.0.1 through TCP/IP but not through Unix Socket file. The permissions on mysql.sock is: ls -la /usr/local/mysql/tmp/ total 0 drwxrwx--- 2 mysql mysql 80 2005-08-24 22:09 ./ drwxr-xr-x 13 root mysql 328 2005-08-22 20:03 ../ srwxrwxrwx 1 mysql mysql 0 2005-08-24 22:09 mysql.sock= Again, I can connect to DB through other programs (non-php) or via commandline and even TCP but not through Unix socket file!! Any ideas? -- PHP Database Mailing List ( http://www.php.net/ ) To unsubscribe, visit: http://www.php.net/unsub.php -- From : Fen lu -- PHP Database Mailing List ( http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- From : Fen lu -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PHP5-MySQL Not Connecting Through Socket
As of this post, this problem has not been solved [For those who get to this link via search engines]. I also tried to downgrade from PHP 5.0.4 to PHP 4.4.0 but the problem still persists. For some reason on my system (Slackware 10.1, kernel 2.6.11.3, MySQL 4.1.13a, Apache 2.0.54), PHP cannot make connection to the database. I was having some success connecting through TCP socket 127.0.0.1 but now I keep getting Lost connection to MySQL server during query! I don't even know what my last resort is at this point. On 8/30/05, Evan J [EMAIL PROTECTED] wrote: Thank you Roger, Yes, I can ping my localhost, designated LAN IP, and 127.0.0.1 just fine. No, I do not run any DNS server on the machine that I am having this problem. The whole point of using locahost Vs. 127.0.0.1 is to avoid the overhead of TCP by using Unix socket file. A system that I'm running PHP and MySQL is a Slackware 10.1 with 2.6.11.3 kernel (Intel x86). I do have a Solaris box but that's entirely irrelevent. :) I have disabled networking connection to MySQL (skip networking) in /etc/my.cfg as I run the necessary programs only on one system. All MySQL users (root and what not) only have privileges to localhost and nothing else. P.S. You may want to reply to php-db@lists.php.net so it would be posted to the mailing-list archive as oppose to directing your response solely to me. :) On 8/30/05, Roger Villarreal [EMAIL PROTECTED] wrote: Yes, sorry I'm sure about having a duble entry for 127.0.0.1 in the hosts file. usally it's one line per IP followed by name then aliases. Can you ping the IP and localhost? Are you using DNS on this box? It sounds like since you can connect OK by using the IP but when try the name you have some kind name resolution error occuring. You may looking at DNS services for name resolution only. I set boxes up to look at files first and DNS second. Now speaking for a Solaris box which is configured differently than other UNIXes. What type of OS are your runing? Also if you can connect with the IP to the server, then check your entry in the mysql database in the user table. You should have an entry for localhost and check that the PRIVILEGES and password are set correctly. All I can offer for now. Later. Roger - Original Message - From: Evan J [EMAIL PROTECTED] To: php-db@lists.php.net Sent: Tuesday, August 30, 2005 2:28 PM Subject: Re: [PHP-DB] PHP5-MySQL Not Connecting Through Socket Roger, Do you mean /etc/hosts? I do have /etc/hosts with the following entries: 127.0.0.1 localhost 127.0.0.1 myhostname.myhostname myhostname On 8/30/05, Roger Villarreal [EMAIL PROTECTED] wrote: Evan Is there an entry in your /etc/host file for localhost? roger - Original Message - From: Evan J [EMAIL PROTECTED] To: php-db@lists.php.net Sent: Tuesday, August 30, 2005 1:01 PM Subject: Re: [PHP-DB] PHP5-MySQL Not Connecting Through Socket I commented out the bind-address and restarted MySQL. Still refuses to make connection through Unix socket. And for permissions, they came back as I was expected; I have created my mysql user to have access to localhost so: mysql -h127.0.0.1 -D dbname -uusername -p # Rejected, obviously mysql -hpublicIP -D dbname -uusername -p # Rejected mysql -hlocalhost -D dbname -uusername -p # Accepted as I expected But yet, PHP only connects to MySQL through TCP (127.0.0.1) but not localhost! On 8/30/05, Bob Allen [EMAIL PROTECTED] wrote: Comment out the bind-address this allows mysqld to bind to all IPs; accordingly determine if you only want it local or externally available. Finally attempt to connect to the mysql server using the mysql -h127.0.0.1 -uusername -p mysql -hpublicIP -uusername -p mysql -hlocalhost -uusername -p you may find the user permissions are the problem. Even when you connect locally mysql sees these as connections the user is not allowed to connect from. Robert Allen, zce Operations, FIO Labs, LLC -Original Message- From: Evan J [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 30, 2005 11:41 AM To: php-db@lists.php.net Subject: Re: [PHP-DB] RE: PHP5-MySQL Not Connecting Through Socket Thank you Robert for the prompt response. 1) Yes, I do have /etc/my.cnf (644 permission) 2) I do have a bind-address directive but it was set to 127.0.0.0 by default. I even changed it to 127.0.0.1 and restarted MySQL; no luck. 3) my.cnf's socket file path and name in both [client] and [mysqld] are the same and have been set accordingly. I am still stumped as of why PHP cannot connect through Unix socket to MySQL! On 8/30/05, Bob Allen [EMAIL PROTECTED] wrote: 1) Do you have a /etc/my.cnf ? 2) In this do you have the bind-address directive set
[PHP-DB] PHP5-MySQL Not Connecting Through Socket
Hi, I am running PHP 5.0.4 and MySQL 4.1.3a. (+Apache 2.0.54) When I run a PHP script that attempts to connect to MySQL I get the following error: Database ERROR:Can't connect to local MySQL server through socket '/usr/local/mysql/tmp/mysql.sock' (13) I have placed my socket file on such location when I was configuring MySQL and PHP was compiled with --with-mysql-sock=/usr/local/mysql/tmp/mysql.sock (and even with /usr/local/mysql/tmp). I even edited my php.ini (/usr/local/php/lib/php.ini, I have installed PHP with --prefix=/usr/local/php) and modified variable: mysql.default_socket = /usr/local/mysql/tmp/mysql.sock It still refuses to connect through the socket! I have also run a simple mysql_connect() script to see if the intended script was the culprit but again, it could not connect to MySQL. phpinfo() indicates the following: MYSQL_SOCKET/usr/local/mysql/tmp/mysql.sock MYSQL_INCLUDE -I/usr/local/mysql/include/mysql MYSQL_LIBS -L/usr/local/mysql/lib/mysql -lmysqlclient And for directives: mysql.default_port no valueno value mysql.default_socket/usr/local/mysql/tmp/mysql.sock /usr/local/mysql/tmp/mysql.sock That being said, I CAN connect to the database via 127.0.0.1 through TCP/IP but not through Unix Socket file. The permissions on mysql.sock is: ls -la /usr/local/mysql/tmp/ total 0 drwxrwx--- 2 mysql mysql 80 2005-08-24 22:09 ./ drwxr-xr-x 13 root mysql 328 2005-08-22 20:03 ../ srwxrwxrwx 1 mysql mysql 0 2005-08-24 22:09 mysql.sock= Again, I can connect to DB through other programs (non-php) or via commandline and even TCP but not through Unix socket file!! Any ideas? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] PHP5-MySQL Not Connecting Through Socket
Comment out the bind-address this allows mysqld to bind to all IPs; accordingly determine if you only want it local or externally available. Finally attempt to connect to the mysql server using the mysql -h127.0.0.1 -uusername -p mysql -hpublicIP -uusername -p mysql -hlocalhost -uusername -p you may find the user permissions are the problem. Even when you connect locally mysql sees these as connections the user is not allowed to connect from. Robert Allen, zce Operations, FIO Labs, LLC -Original Message- From: Evan J [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 30, 2005 11:41 AM To: php-db@lists.php.net Subject: Re: [PHP-DB] RE: PHP5-MySQL Not Connecting Through Socket Thank you Robert for the prompt response. 1) Yes, I do have /etc/my.cnf (644 permission) 2) I do have a bind-address directive but it was set to 127.0.0.0 by default. I even changed it to 127.0.0.1 and restarted MySQL; no luck. 3) my.cnf's socket file path and name in both [client] and [mysqld] are the same and have been set accordingly. I am still stumped as of why PHP cannot connect through Unix socket to MySQL! On 8/30/05, Bob Allen [EMAIL PROTECTED] wrote: 1) Do you have a /etc/my.cnf ? 2) In this do you have the bind-address directive set? i.e. [ bind-address = 127.0.0.1] this is the default for debian packages versions. 3) Also confirm the my.cnf reflects the mysql.sock path properly as well. Robert Allen, zce Operations, FIO Labs LLC -Original Message- From: Evan J [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 30, 2005 7:57 AM To: php-db@lists.php.net Subject: PHP5-MySQL Not Connecting Through Socket Hi, I am running PHP 5.0.4 and MySQL 4.1.3a. (+Apache 2.0.54) When I run a PHP script that attempts to connect to MySQL I get the following error: Database ERROR:Can't connect to local MySQL server through socket '/usr/local/mysql/tmp/mysql.sock' (13) I have placed my socket file on such location when I was configuring MySQL and PHP was compiled with --with-mysql-sock=/usr/local/mysql/tmp/mysql.sock (and even with /usr/local/mysql/tmp). I even edited my php.ini (/usr/local/php/lib/php.ini, I have installed PHP with --prefix=/usr/local/php) and modified variable: mysql.default_socket = /usr/local/mysql/tmp/mysql.sock It still refuses to connect through the socket! I have also run a simple mysql_connect() script to see if the intended script was the culprit but again, it could not connect to MySQL. phpinfo() indicates the following: MYSQL_SOCKET/usr/local/mysql/tmp/mysql.sock MYSQL_INCLUDE -I/usr/local/mysql/include/mysql MYSQL_LIBS -L/usr/local/mysql/lib/mysql -lmysqlclient And for directives: mysql.default_port no valueno value mysql.default_socket/usr/local/mysql/tmp/mysql.sock /usr/local/mysql/tmp/mysql.sock That being said, I CAN connect to the database via 127.0.0.1 through TCP/IP but not through Unix Socket file. The permissions on mysql.sock is: ls -la /usr/local/mysql/tmp/ total 0 drwxrwx--- 2 mysql mysql 80 2005-08-24 22:09 ./ drwxr-xr-x 13 root mysql 328 2005-08-22 20:03 ../ srwxrwxrwx 1 mysql mysql 0 2005-08-24 22:09 mysql.sock= Again, I can connect to DB through other programs (non-php) or via commandline and even TCP but not through Unix socket file!! Any ideas? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PHP5-MySQL Not Connecting Through Socket
I commented out the bind-address and restarted MySQL. Still refuses to make connection through Unix socket. And for permissions, they came back as I was expected; I have created my mysql user to have access to localhost so: mysql -h127.0.0.1 -D dbname -uusername -p # Rejected, obviously mysql -hpublicIP -D dbname -uusername -p # Rejected mysql -hlocalhost -D dbname -uusername -p # Accepted as I expected But yet, PHP only connects to MySQL through TCP (127.0.0.1) but not localhost! On 8/30/05, Bob Allen [EMAIL PROTECTED] wrote: Comment out the bind-address this allows mysqld to bind to all IPs; accordingly determine if you only want it local or externally available. Finally attempt to connect to the mysql server using the mysql -h127.0.0.1 -uusername -p mysql -hpublicIP -uusername -p mysql -hlocalhost -uusername -p you may find the user permissions are the problem. Even when you connect locally mysql sees these as connections the user is not allowed to connect from. Robert Allen, zce Operations, FIO Labs, LLC -Original Message- From: Evan J [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 30, 2005 11:41 AM To: php-db@lists.php.net Subject: Re: [PHP-DB] RE: PHP5-MySQL Not Connecting Through Socket Thank you Robert for the prompt response. 1) Yes, I do have /etc/my.cnf (644 permission) 2) I do have a bind-address directive but it was set to 127.0.0.0 by default. I even changed it to 127.0.0.1 and restarted MySQL; no luck. 3) my.cnf's socket file path and name in both [client] and [mysqld] are the same and have been set accordingly. I am still stumped as of why PHP cannot connect through Unix socket to MySQL! On 8/30/05, Bob Allen [EMAIL PROTECTED] wrote: 1) Do you have a /etc/my.cnf ? 2) In this do you have the bind-address directive set? i.e. [ bind-address = 127.0.0.1] this is the default for debian packages versions. 3) Also confirm the my.cnf reflects the mysql.sock path properly as well. Robert Allen, zce Operations, FIO Labs LLC -Original Message- From: Evan J [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 30, 2005 7:57 AM To: php-db@lists.php.net Subject: PHP5-MySQL Not Connecting Through Socket Hi, I am running PHP 5.0.4 and MySQL 4.1.3a. (+Apache 2.0.54) When I run a PHP script that attempts to connect to MySQL I get the following error: Database ERROR:Can't connect to local MySQL server through socket '/usr/local/mysql/tmp/mysql.sock' (13) I have placed my socket file on such location when I was configuring MySQL and PHP was compiled with --with-mysql-sock=/usr/local/mysql/tmp/mysql.sock (and even with /usr/local/mysql/tmp). I even edited my php.ini (/usr/local/php/lib/php.ini, I have installed PHP with --prefix=/usr/local/php) and modified variable: mysql.default_socket = /usr/local/mysql/tmp/mysql.sock It still refuses to connect through the socket! I have also run a simple mysql_connect() script to see if the intended script was the culprit but again, it could not connect to MySQL. phpinfo() indicates the following: MYSQL_SOCKET/usr/local/mysql/tmp/mysql.sock MYSQL_INCLUDE -I/usr/local/mysql/include/mysql MYSQL_LIBS -L/usr/local/mysql/lib/mysql -lmysqlclient And for directives: mysql.default_port no valueno value mysql.default_socket/usr/local/mysql/tmp/mysql.sock /usr/local/mysql/tmp/mysql.sock That being said, I CAN connect to the database via 127.0.0.1 through TCP/IP but not through Unix Socket file. The permissions on mysql.sock is: ls -la /usr/local/mysql/tmp/ total 0 drwxrwx--- 2 mysql mysql 80 2005-08-24 22:09 ./ drwxr-xr-x 13 root mysql 328 2005-08-22 20:03 ../ srwxrwxrwx 1 mysql mysql 0 2005-08-24 22:09 mysql.sock= Again, I can connect to DB through other programs (non-php) or via commandline and even TCP but not through Unix socket file!! Any ideas? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PHP5-MySQL Not Connecting Through Socket
Roger, Do you mean /etc/hosts? I do have /etc/hosts with the following entries: 127.0.0.1 localhost 127.0.0.1 myhostname.myhostname myhostname On 8/30/05, Roger Villarreal [EMAIL PROTECTED] wrote: Evan Is there an entry in your /etc/host file for localhost? roger - Original Message - From: Evan J [EMAIL PROTECTED] To: php-db@lists.php.net Sent: Tuesday, August 30, 2005 1:01 PM Subject: Re: [PHP-DB] PHP5-MySQL Not Connecting Through Socket I commented out the bind-address and restarted MySQL. Still refuses to make connection through Unix socket. And for permissions, they came back as I was expected; I have created my mysql user to have access to localhost so: mysql -h127.0.0.1 -D dbname -uusername -p # Rejected, obviously mysql -hpublicIP -D dbname -uusername -p # Rejected mysql -hlocalhost -D dbname -uusername -p # Accepted as I expected But yet, PHP only connects to MySQL through TCP (127.0.0.1) but not localhost! On 8/30/05, Bob Allen [EMAIL PROTECTED] wrote: Comment out the bind-address this allows mysqld to bind to all IPs; accordingly determine if you only want it local or externally available. Finally attempt to connect to the mysql server using the mysql -h127.0.0.1 -uusername -p mysql -hpublicIP -uusername -p mysql -hlocalhost -uusername -p you may find the user permissions are the problem. Even when you connect locally mysql sees these as connections the user is not allowed to connect from. Robert Allen, zce Operations, FIO Labs, LLC -Original Message- From: Evan J [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 30, 2005 11:41 AM To: php-db@lists.php.net Subject: Re: [PHP-DB] RE: PHP5-MySQL Not Connecting Through Socket Thank you Robert for the prompt response. 1) Yes, I do have /etc/my.cnf (644 permission) 2) I do have a bind-address directive but it was set to 127.0.0.0 by default. I even changed it to 127.0.0.1 and restarted MySQL; no luck. 3) my.cnf's socket file path and name in both [client] and [mysqld] are the same and have been set accordingly. I am still stumped as of why PHP cannot connect through Unix socket to MySQL! On 8/30/05, Bob Allen [EMAIL PROTECTED] wrote: 1) Do you have a /etc/my.cnf ? 2) In this do you have the bind-address directive set? i.e. [ bind-address = 127.0.0.1] this is the default for debian packages versions. 3) Also confirm the my.cnf reflects the mysql.sock path properly as well. Robert Allen, zce Operations, FIO Labs LLC -Original Message- From: Evan J [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 30, 2005 7:57 AM To: php-db@lists.php.net Subject: PHP5-MySQL Not Connecting Through Socket Hi, I am running PHP 5.0.4 and MySQL 4.1.3a. (+Apache 2.0.54) When I run a PHP script that attempts to connect to MySQL I get the following error: Database ERROR:Can't connect to local MySQL server through socket '/usr/local/mysql/tmp/mysql.sock' (13) I have placed my socket file on such location when I was configuring MySQL and PHP was compiled with --with-mysql-sock=/usr/local/mysql/tmp/mysql.sock (and even with /usr/local/mysql/tmp). I even edited my php.ini (/usr/local/php/lib/php.ini, I have installed PHP with --prefix=/usr/local/php) and modified variable: mysql.default_socket = /usr/local/mysql/tmp/mysql.sock It still refuses to connect through the socket! I have also run a simple mysql_connect() script to see if the intended script was the culprit but again, it could not connect to MySQL. phpinfo() indicates the following: MYSQL_SOCKET/usr/local/mysql/tmp/mysql.sock MYSQL_INCLUDE -I/usr/local/mysql/include/mysql MYSQL_LIBS -L/usr/local/mysql/lib/mysql -lmysqlclient And for directives: mysql.default_port no valueno value mysql.default_socket/usr/local/mysql/tmp/mysql.sock /usr/local/mysql/tmp/mysql.sock That being said, I CAN connect to the database via 127.0.0.1 through TCP/IP but not through Unix Socket file. The permissions on mysql.sock is: ls -la /usr/local/mysql/tmp/ total 0 drwxrwx--- 2 mysql mysql 80 2005-08-24 22:09 ./ drwxr-xr-x 13 root mysql 328 2005-08-22 20:03 ../ srwxrwxrwx 1 mysql mysql 0 2005-08-24 22:09 mysql.sock= Again, I can connect to DB through other programs (non-php) or via commandline and even TCP but not through Unix socket file!! Any ideas? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http
Re: [PHP-DB] PHP5-MySQL Not Connecting Through Socket
Thank you Roger, Yes, I can ping my localhost, designated LAN IP, and 127.0.0.1 just fine. No, I do not run any DNS server on the machine that I am having this problem. The whole point of using locahost Vs. 127.0.0.1 is to avoid the overhead of TCP by using Unix socket file. A system that I'm running PHP and MySQL is a Slackware 10.1 with 2.6.11.3 kernel (Intel x86). I do have a Solaris box but that's entirely irrelevent. :) I have disabled networking connection to MySQL (skip networking) in /etc/my.cfg as I run the necessary programs only on one system. All MySQL users (root and what not) only have privileges to localhost and nothing else. P.S. You may want to reply to php-db@lists.php.net so it would be posted to the mailing-list archive as oppose to directing your response solely to me. :) On 8/30/05, Roger Villarreal [EMAIL PROTECTED] wrote: Yes, sorry I'm sure about having a duble entry for 127.0.0.1 in the hosts file. usally it's one line per IP followed by name then aliases. Can you ping the IP and localhost? Are you using DNS on this box? It sounds like since you can connect OK by using the IP but when try the name you have some kind name resolution error occuring. You may looking at DNS services for name resolution only. I set boxes up to look at files first and DNS second. Now speaking for a Solaris box which is configured differently than other UNIXes. What type of OS are your runing? Also if you can connect with the IP to the server, then check your entry in the mysql database in the user table. You should have an entry for localhost and check that the PRIVILEGES and password are set correctly. All I can offer for now. Later. Roger - Original Message - From: Evan J [EMAIL PROTECTED] To: php-db@lists.php.net Sent: Tuesday, August 30, 2005 2:28 PM Subject: Re: [PHP-DB] PHP5-MySQL Not Connecting Through Socket Roger, Do you mean /etc/hosts? I do have /etc/hosts with the following entries: 127.0.0.1 localhost 127.0.0.1 myhostname.myhostname myhostname On 8/30/05, Roger Villarreal [EMAIL PROTECTED] wrote: Evan Is there an entry in your /etc/host file for localhost? roger - Original Message - From: Evan J [EMAIL PROTECTED] To: php-db@lists.php.net Sent: Tuesday, August 30, 2005 1:01 PM Subject: Re: [PHP-DB] PHP5-MySQL Not Connecting Through Socket I commented out the bind-address and restarted MySQL. Still refuses to make connection through Unix socket. And for permissions, they came back as I was expected; I have created my mysql user to have access to localhost so: mysql -h127.0.0.1 -D dbname -uusername -p # Rejected, obviously mysql -hpublicIP -D dbname -uusername -p # Rejected mysql -hlocalhost -D dbname -uusername -p # Accepted as I expected But yet, PHP only connects to MySQL through TCP (127.0.0.1) but not localhost! On 8/30/05, Bob Allen [EMAIL PROTECTED] wrote: Comment out the bind-address this allows mysqld to bind to all IPs; accordingly determine if you only want it local or externally available. Finally attempt to connect to the mysql server using the mysql -h127.0.0.1 -uusername -p mysql -hpublicIP -uusername -p mysql -hlocalhost -uusername -p you may find the user permissions are the problem. Even when you connect locally mysql sees these as connections the user is not allowed to connect from. Robert Allen, zce Operations, FIO Labs, LLC -Original Message- From: Evan J [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 30, 2005 11:41 AM To: php-db@lists.php.net Subject: Re: [PHP-DB] RE: PHP5-MySQL Not Connecting Through Socket Thank you Robert for the prompt response. 1) Yes, I do have /etc/my.cnf (644 permission) 2) I do have a bind-address directive but it was set to 127.0.0.0 by default. I even changed it to 127.0.0.1 and restarted MySQL; no luck. 3) my.cnf's socket file path and name in both [client] and [mysqld] are the same and have been set accordingly. I am still stumped as of why PHP cannot connect through Unix socket to MySQL! On 8/30/05, Bob Allen [EMAIL PROTECTED] wrote: 1) Do you have a /etc/my.cnf ? 2) In this do you have the bind-address directive set? i.e. [ bind-address = 127.0.0.1] this is the default for debian packages versions. 3) Also confirm the my.cnf reflects the mysql.sock path properly as well. Robert Allen, zce Operations, FIO Labs LLC -Original Message- From: Evan J [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 30, 2005 7:57 AM To: php-db@lists.php.net Subject: PHP5-MySQL Not Connecting Through Socket Hi, I am running PHP 5.0.4 and MySQL 4.1.3a. (+Apache 2.0.54) When I run a PHP script that attempts to connect to MySQL I get the following error: Database ERROR:Can't connect to local MySQL server