|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi,
The local mysql server is running on my Macbook. I can access it through the console client: $ mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.0.45 MySQL Community Server (GPL) Type ';' or '\h' for . Type '\c' to clear the buffer. mysql> But when I launch a PHP script that tries to connect to it, I get an error: $link = mysql_connect("localhost", "root", ""); Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) Any ideas what's going on? |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
scorpionbilli@googlemail.com wrote:
> Hi, > > The local mysql server is running on my Macbook. I can access it > through the console client: > > $ mysql -u root > Welcome to the MySQL monitor. Commands end with ; or \g. > Your MySQL connection id is 4 > Server version: 5.0.45 MySQL Community Server (GPL) > > Type ';' or '\h' for . Type '\c' to clear the buffer. > mysql> > > But when I launch a PHP script that tries to connect to it, I get an > error: > > $link = mysql_connect("localhost", "root", ""); > > Warning: mysql_connect(): Can't connect to local MySQL server through > socket '/var/mysql/mysql.sock' (2) > > Any ideas what's going on? > Does /var/mysql/mysql.sock exist? What are its permissions? -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Apr 8, 9:37 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> scorpionbi...@googlemail.com wrote: > > Hi, > > > The local mysql server is running on my Macbook. I can access it > > through the console client: > > > $ mysql -u root > > Welcome to the MySQL monitor. Commands end with ; or \g. > > Your MySQL connection id is 4 > > Server version: 5.0.45 MySQL Community Server (GPL) > > > Type ';' or '\h' for . Type '\c' to clear the buffer. > > mysql> > > > But when I launch a PHP script that tries to connect to it, I get an > > error: > > > $link = mysql_connect("localhost", "root", ""); > > > Warning: mysql_connect(): Can't connect to local MySQL server through > > socket '/var/mysql/mysql.sock' (2) > > > Any ideas what's going on? > > Does /var/mysql/mysql.sock exist? What are its permissions? > > -- > ================== > Remove the "x" from my email address > Jerry Stuckle > JDS Computer Training Corp. > jstuck...@attglobal.net > ================== No, /var/mysql does't exist. locate mysql.sock shows one at /private/ tmp/mysql.sock . Should I configure PHP to use that, or configure MySQL to place the socket somewhere else? |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Apr 8, 9:47 pm, scorpionbi...@googlemail.com wrote:
> On Apr 8, 9:37 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote: > > > > > scorpionbi...@googlemail.com wrote: > > > Hi, > > > > The local mysql server is running on my Macbook. I can access it > > > through the console client: > > > > $ mysql -u root > > > Welcome to the MySQL monitor. Commands end with ; or \g. > > > Your MySQL connection id is 4 > > > Server version: 5.0.45 MySQL Community Server (GPL) > > > > Type ';' or '\h' for . Type '\c' to clear the buffer. > > > mysql> > > > > But when I launch a PHP script that tries to connect to it, I get an > > > error: > > > > $link = mysql_connect("localhost", "root", ""); > > > > Warning: mysql_connect(): Can't connect to local MySQL server through > > > socket '/var/mysql/mysql.sock' (2) > > > > Any ideas what's going on? > > > Does /var/mysql/mysql.sock exist? What are its permissions? > > > -- > > ================== > > Remove the "x" from my email address > > Jerry Stuckle > > JDS Computer Training Corp. > > jstuck...@attglobal.net > > ================== > > No, /var/mysql does't exist. locate mysql.sock shows one at /private/ > tmp/mysql.sock . > > Should I configure PHP to use that, or configure MySQL to place the > socket somewhere else? I forgot to add: /var, /tmp and /etc are all linked to /private subdirectories, so the mysql.sock would be reachable at /tmp/ mysql.sock . Mh. I'll try symlinking /var/mysql/mysql.sock to that. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On Apr 8, 9:54 pm, scorpionbi...@googlemail.com wrote:
> On Apr 8, 9:47 pm, scorpionbi...@googlemail.com wrote: > > > > > On Apr 8, 9:37 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote: > > > > scorpionbi...@googlemail.com wrote: > > > > Hi, > > > > > The local mysql server is running on my Macbook. I can access it > > > > through the console client: > > > > > $ mysql -u root > > > > Welcome to the MySQL monitor. Commands end with ; or \g. > > > > Your MySQL connection id is 4 > > > > Server version: 5.0.45 MySQL Community Server (GPL) > > > > > Type ';' or '\h' for . Type '\c' to clear the buffer. > > > > mysql> > > > > > But when I launch a PHP script that tries to connect to it, I get an > > > > error: > > > > > $link = mysql_connect("localhost", "root", ""); > > > > > Warning: mysql_connect(): Can't connect to local MySQL server through > > > > socket '/var/mysql/mysql.sock' (2) > > > > > Any ideas what's going on? > > > > Does /var/mysql/mysql.sock exist? What are its permissions? > > > > -- > > > ================== > > > Remove the "x" from my email address > > > Jerry Stuckle > > > JDS Computer Training Corp. > > > jstuck...@attglobal.net > > > ================== > > > No, /var/mysql does't exist. locate mysql.sock shows one at /private/ > > tmp/mysql.sock . > > > Should I configure PHP to use that, or configure MySQL to place the > > socket somewhere else? > > I forgot to add: /var, /tmp and /etc are all linked to /private > subdirectories, so the mysql.sock would be reachable at /tmp/ > mysql.sock . > > Mh. I'll try symlinking /var/mysql/mysql.sock to that. Don't have access to root right now. Is there any other way of doing this? |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
>The local mysql server is running on my Macbook. I can access it
>through the console client: When you connect using a socket, the server and the client must agree on the location of the socket. >$ mysql -u root >Welcome to the MySQL monitor. Commands end with ; or \g. >Your MySQL connection id is 4 >Server version: 5.0.45 MySQL Community Server (GPL) > >Type ';' or '\h' for . Type '\c' to clear the buffer. $ mysql -h localhost -u root >mysql> At this point, type \s [ENTER] at the prompt. It will tell you a number of things. Look for the line that tells you about the path name to the socket (usually ends in 'mysql.sock'), e.g.: mysql>\s .... UNIX Socket: /tmp/mysql.sock .... >But when I launch a PHP script that tries to connect to it, I get an >error: > >$link = mysql_connect("localhost", "root", ""); > >Warning: mysql_connect(): Can't connect to local MySQL server through >socket '/var/mysql/mysql.sock' (2) perror 2 on my system is "no such file or directory". > >Any ideas what's going on? PHP doesn't know the correct path for the socket. In php.ini, there's a variable setting (likely commented out or missing in the default distribution file): mysql.default_socket = "/tmp/mysql.sock" Now restart your web server. /tmp/mysql.sock represents the correct socket pathname. Don't assume it is literally correct just because that's what it is on my system (FreeBSD). It is important that the server and the client AGREE, much more important than what the actual path is. Your server and the command-line client already seem to agree, so use what they're using. |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
Greetings, scorpionbilli@googlemail.com.
In reply to Your message dated Tuesday, April 8, 2008, 22:23:20, > The local mysql server is running on my Macbook. I can access it > through the console client: > $ mysql -u root > Welcome to the MySQL monitor. Commands end with ; or \g. > Your MySQL connection id is 4 > Server version: 5.0.45 MySQL Community Server (GPL) > Type ';' or '\h' for . Type '\c' to clear the buffer. mysql>> > But when I launch a PHP script that tries to connect to it, I get an > error: > $link = mysql_connect("localhost", "root", ""); First: Don't use 'root' in any other case than maintenance purposes. > Warning: mysql_connect(): Can't connect to local MySQL server through > socket '/var/mysql/mysql.sock' (2) > Any ideas what's going on? RTFM, seriously. http://www.php.net/manual/en/function.mysql-connect.php Note: Whenever you specify "localhost" or "localhost:port" as server, the MySQL client library will override this and try to connect to a local socket (named pipe on Windows). If you want to use TCP/IP, use "127.0.0.1" instead of "localhost". If the MySQL client library tries to connect to the wrong local socket, you should set the correct path as Runtime Configuration in your PHP configuration and leave the server field blank. From my experience, this may cause some unexpected things, at least in Windows. Try $link = mysql_connect("127.0.0.1", "username", "password"); -- Sincerely Yours, AnrDaemon <anrdaemon@freemail.ru> |
|
![]() |
| Outils de la discussion | |
|
|