![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
How do you configure the mysqli socket in php.ini? I'm getting this sql socket warning:warning: msqli::mysqli() [mysqli.mysqli]: (HY000/2002): Can't connect to local MysQL server through socket 'var/mysql/mysqlsock' (2) I have the mysql socket and the mysqli socket set to the same location /tmp/mysql.sock. |
|
In my.cnf it is set to tmp/mysql.sock [client] port =3306 socket=/tmp/mysql.sock in php.ini mysql.default_socket = /tmp/mysql.sock mysqli.default_port = 3306 ; MySQL defaults. mysqli.default_socket = /tmp/mysql.sock |
|
are they supposed to be different locations? |
#3
| |||
| |||
|
|
JRough wrote: How do you configure the mysqli socket in php.ini? I'm getting this sql socket warning:warning: *msqli::mysqli() [mysqli.mysqli]: (HY000/2002): *Can't connect to local MysQL server through socket 'var/mysql/mysqlsock' (2) I have the mysql socket and the mysqli socket set to the same location /tmp/mysql.sock. Why not use the defaults? Makes it far simpler for you. In my.cnf it is set to tmp/mysql.sock [client] port =3306 socket=/tmp/mysql.sock in php.ini mysql.default_socket = */tmp/mysql.sock mysqli.default_port = 3306 ; MySQL defaults. mysqli.default_socket = */tmp/mysql.sock Assuming here, you are using the php through apache (or any other web server), did you remember to restart the web service? If not, then the old settings are used until you restart the service. are they supposed to be different locations? No, as mysql has just one socket. -- * //Aho |
#4
| ||||
| ||||
|
|
These are the defaults in the php.ini. They say default is /tmp/ mysql.sock. |
|
Do you mean to remove the reference in my.cnf ? it also says /tmp/ mysql.sock. |
|
I don't know where the var/mysql/mysqlsock(2) error is coming from. Does it mean there are 2 mysql sockets? |
|
I don't think I changed anything and I thought it was working but I just started writing a script using mysqli. |
#5
| |||
| |||
|
|
JRough wrote: These are the defaults in the php.ini. *They say default is /tmp/ mysql.sock. Default in a php.ini is empty values, at least in the Linux distros and Unixes I have used. Do you mean to remove the reference in my.cnf ? *it also says /tmp/ mysql.sock. It's a quite unusual location for the socket file, and feels quite unsecure to have it in /tmp. I would have set it in /var/run/mysqld/mysqld.sock (if you have a such directory), it gives a slightly more restrictions than havingit in /tmp. I don't know where the var/mysql/mysqlsock(2) error is coming from. Does it mean there are 2 mysql sockets? No, it's the error number. It tells you that it tries to look for the socket in var/mysql/mysqlsock, which would be relative to the directory from where the php is executed (would say that the original path was missing the leading /). You can always try to connect to the hostname of the machine (instead of localhost/127.0.0.1), then it should connect to the port instead of usingthe socket, which would be a work around for your configuration troubles. I don't think I changed anything and I thought it was working but I just started writing a script using mysqli. Using packages released by the OS maintainer are always better than using3rd party packages or compile those yourself, as those official packages will always work. -- * //Aho |
#6
| |||
| |||
|
|
JRough wrote: These are the defaults in the php.ini. *They say default is /tmp/ mysql.sock. Default in a php.ini is empty values, at least in the Linux distros and Unixes I have used. Do you mean to remove the reference in my.cnf ? *it also says /tmp/ mysql.sock. It's a quite unusual location for the socket file, and feels quite unsecure to have it in /tmp. I would have set it in /var/run/mysqld/mysqld.sock (if you have a such directory), it gives a slightly more restrictions than havingit in /tmp. I don't know where the var/mysql/mysqlsock(2) error is coming from. Does it mean there are 2 mysql sockets? No, it's the error number. It tells you that it tries to look for the socket in var/mysql/mysqlsock, which would be relative to the directory from where the php is executed (would say that the original path was missing the leading /). You can always try to connect to the hostname of the machine (instead of localhost/127.0.0.1), then it should connect to the port instead of usingthe socket, which would be a work around for your configuration troubles. I don't think I changed anything and I thought it was working but I just started writing a script using mysqli. Using packages released by the OS maintainer are always better than using3rd party packages or compile those yourself, as those official packages will always work. -- * //Aho Do I have to open up 3306 on the router? |
#7
| |||
| |||
|
|
JRough wrote: These are the defaults in the php.ini. *They say default is /tmp/ mysql.sock. Default in a php.ini is empty values, at least in the Linux distros and Unixes I have used. Do you mean to remove the reference in my.cnf ? *it also says /tmp/ mysql.sock. It's a quite unusual location for the socket file, and feels quite unsecure to have it in /tmp. I would have set it in /var/run/mysqld/mysqld.sock (if you have a such directory), it gives a slightly more restrictions than havingit in /tmp. I don't know where the var/mysql/mysqlsock(2) error is coming from. Does it mean there are 2 mysql sockets? No, it's the error number. It tells you that it tries to look for the socket in var/mysql/mysqlsock, which would be relative to the directory from where the php is executed (would say that the original path was missing the leading /). You can always try to connect to the hostname of the machine (instead of localhost/127.0.0.1), then it should connect to the port instead of usingthe socket, which would be a work around for your configuration troubles. I don't think I changed anything and I thought it was working but I just started writing a script using mysqli. Using packages released by the OS maintainer are always better than using3rd party packages or compile those yourself, as those official packages will always work. -- * //Aho I did try changing all the mysql socket defaults to where it thinks it |
#8
| ||||
| ||||
|
|
I commented out the defaul settings in php.ini to see if the socket would change to another default and get rid of the error message but it didn't. So somewhere in my Mac, Apple is telling it to go to the var/mysql/ mysqlsock location I would like to find out where. |
|
But it was working previously although I had it configured to a software IP addres. I don't have a static IP address. It is software enabled. So mysql requests were working find because it updates the IP address and the name points to the latest IP. That was all working until I got a new router from AT&T . It wouldn't reroute web traffoce to the outside IP so to get this script done I turned it back to localhost for testing. That should work but now it isn't. It is giving the socket error. Maybe it was there before but I wasn't using localhost. |
|
Do I have to open up 3306 on the router? |
|
I did try changing all the mysql socket defaults to where it thinks it is /var/mysql/mysql.socket. I changed the mysqli default socket, the mysql default socket and the my.conf to /var/mysql/mysql.socket I checked the permission of this directory. that is the only other thing I think it can be. drwxr-xr-x 2 _mysql wheel 68 Dec 28 11:56 . drwxr-xr-x 26 root wheel 884 Dec 28 11:56 .. |
#9
| |||
| |||
|
|
JRough wrote: I commented out the defaul settings in php.ini to see if the socket would change to another default and get rid of the error message but it didn't. So somewhere in my Mac, Apple is telling it to go to the var/mysql/ mysqlsock location *I would like to find out where. PHP has a default built in path in Unix and Linux, it kind of looks like broken IMHO. Keep in mind that you need to restart the apache (stop/start) before changes in the php.ini will take affect. But it was working previously although I had it configured to a software IP addres. *I don't have a static IP address. *It is software enabled. So mysql requests were working find because it updates the IP address and the name points to the latest IP. *That was all working until I got a new router from AT&T . * It wouldn't reroute web traffoce to the outside IP so to get this script done I turned it back to localhost for testing. *That should work but now it isn't. *It is giving the socket error. *Maybe it was there before but I wasn't using localhost.. localhost calls are directed to use the socket, which is the big difference between the two cases, as it previously used tcp. Do I have to open up 3306 on the router? Only if traffic would go somehow out from the router and then back in, it shouldn't ever get our of the router. I did try changing all the mysql socket defaults to where it thinks it is /var/mysql/mysql.socket. I changed the mysqli default socket, the mysql default socket and the my.conf to /var/mysql/mysql.socket I checked the permission of this directory. *that is the only other thing I think it can be. drwxr-xr-x * 2 _mysql *wheel * 68 Dec 28 11:56 . drwxr-xr-x *26 root * *wheel *884 Dec 28 11:56 .. The permission looks okey, how about the socket file itself? srwxrwxrwx 1 mysql mysql 0 2009-10-01 06:58 /var/run/mysqld/mysqld.sock If php still says "var/mysql/mysqlsock" after restart of apache, then check if you run suExec on apache, as that will allow you to have a custom php.inifor each "user", in that case the php.ini would be in the users "home directory". -- * //Aho |
#10
| |||
| |||
|
|
Okay, I think the problem is closer to being solved. I changed the my.cnf and forced it to find the mysql socket where it is asking to /var/mysql/mysql.socket. In fact, I went to the /var/mysql/mysql.sock directory and there is a mysql.socket file there. So I guess it was conflicting with the one in the php.ini /tmp/mysql.socket. I changed the php.ini defaults in both places, mysql and mysqli, and I changed the my.conf all to /var/mysql/mysql.socket. then I tried to restart mysql in the control panel and I could stop it but not restart it. So I don't know if it is running or not. I can't seem to do a ps aux | mysql without an error. I tried to find the running process. |
|
Somehow I can't shutdown the old mysqld process and start the new one with the socket hopefully in the right place. |
![]() |
| Thread Tools | |
| Display Modes | |
| |