![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
In php I can use:- mysql_connect("localhost", $user,$password); mysql_select_db($database); but using C API I have to use this:- mysql_real_connect(&mysql,"127.0.0.1",USERNAME,PAS SWORD,DATABASE,0,"",0) "localhost" or a null "" for the host, simply do not work.. anyone care to comment? |
#3
| |||
| |||
|
| In php I can use:- mysql_connect("localhost", $user,$password); mysql_select_db($database); but using C API I have to use this:- mysql_real_connect(&mysql,"127.0.0.1",USERNAME,PAS SWORD,DATABASE,0,"",0) "localhost" or a null "" for the host, simply do not work.. anyone care to comment? they are different databases, in each case, but the same user/password. |
#4
| |||
| |||
|
|
The Natural Philosopher <tnp (AT) invalid (DOT) invalid> writes: In php I can use:- mysql_connect("localhost", $user,$password); mysql_select_db($database); but using C API I have to use this:- mysql_real_connect(&mysql,"127.0.0.1",USERNAME,PAS SWORD,DATABASE,0,"",0) "localhost" or a null "" for the host, simply do not work.. anyone care to comment? The Mysql client library takes a different view of "localhost" than the rest of the world does. Instead of resolving it like it would any other host name, it takes it as a request to connect to the local domain socket. I suspect that PHP may be resolving the host name itself, and passing the IP address to the C function. So that suggests that my myqsld is not actually using a unix socket, but |
#5
| |||
| |||
|
|
Sherm Pendley wrote: The Natural Philosopher <tnp (AT) invalid (DOT) invalid> writes: In php I can use:- mysql_connect("localhost", $user,$password); mysql_select_db($database); but using C API I have to use this:- mysql_real_connect(&mysql,"127.0.0.1",USERNAME,PAS SWORD,DATABASE,0,"",0) "localhost" or a null "" for the host, simply do not work.. anyone care to comment? The Mysql client library takes a different view of "localhost" than the rest of the world does. Instead of resolving it like it would any other host name, it takes it as a request to connect to the local domain socket. I suspect that PHP may be resolving the host name itself, and passing the IP address to the C function. So that suggests that my myqsld is not actually using a unix socket, but an IP socket only? How would I tell? |
#6
| |||
| |||
|
| In php I can use:- mysql_connect("localhost", $user,$password); mysql_select_db($database); but using C API I have to use this:- mysql_real_connect(&mysql,"127.0.0.1",USERNAME,PAS SWORD,DATABASE,0,"",0) "localhost" or a null "" for the host, simply do not work.. anyone care to comment? they are different databases, in each case, but the same user/password. |
#7
| |||
| |||
|
|
mysql_real_connect(&mysql,"127.0.0.1",USERNAME,PAS SWORD,DATABASE,0,"",0) "localhost" or a null "" for the host, simply do not work.. anyone care to comment? |
#8
| |||
| |||
|
|
mysql_real_connect(&mysql,"127.0.0.1",USERNAME,PAS SWORD,DATABASE,0,"",0) "localhost" or a null "" for the host, simply do not work.. anyone care to comment? You have a configuration problem of some sort. Connecting to the Unix socket from the C library should work. The socket is normally named /tmp/mysql.sock -- any chance an overzealous disk cleanup script deleted it? |
#9
| |||
| |||
|
|
John Levine wrote: mysql_real_connect(&mysql,"127.0.0.1",USERNAME,PAS SWORD,DATABASE,0,"",0) "localhost" or a null "" for the host, simply do not work.. anyone care to comment? You have a configuration problem of some sort. Connecting to the Unix socket from the C library should work. The socket is normally named /tmp/mysql.sock -- any chance an overzealous disk cleanup script deleted it? It could also be under /var/run or even /var/lib (either is betetr than /tmp for the reasons given). I think this is down to the standard debian configuration actually;- |
![]() |
| Thread Tools | |
| Display Modes | |
| |