473,396 Members | 1,683 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

MySQL server running, PHP can't connect

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 'help;' or '\h' for help. 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?
Apr 8 '08 #1
5 2604
sc***********@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 'help;' or '\h' for help. 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.
js*******@attglobal.net
==================

Apr 8 '08 #2
On Apr 8, 9:37 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
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 'help;' or '\h' for help. 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?
Apr 8 '08 #3
On Apr 8, 9:47 pm, scorpionbi...@googlemail.com wrote:
On Apr 8, 9:37 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
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 'help;' or '\h' for help. 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.
Apr 8 '08 #4
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.netwrote:
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 'help;' or '\h' for help. 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?
Apr 8 '08 #5
Greetings, sc***********@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 'help;' or '\h' for help. 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 <an*******@freemail.ru>

Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ryan Stewart | last post by:
I'm running MySQL server on a WinXP box at home. I have a cable modem/router. I've set up port forwarding on port 3306 to the machine running MySQL. I can connect locally just fine, but when I try...
0
by: Ian | last post by:
Dear All, I just downloaded & installed MYSQL. It seemed to work and I can start it and enter my password and change a directory but that is about all. I have been ready and playing "hit & miss"...
0
by: Mark Adams | last post by:
I really need some help with this. MySQL will not start on boot despite everything I've done to make sure that it is set to do so. When I start it as root from a terminal with...
2
by: Sean Berry | last post by:
I have downloaded the source code for mysql-3.23.58. I unzip and untarred it and ran $ ./configure --prefix=/usr/local --localstatedir=/usr/local/mysql $ make $ make install $...
1
by: jiing | last post by:
Now let me describe what I have done and my purpose: Originally, I want to user ports to install phpBB But I found that phpBB doesn't support mysql 5.x (but the ports installed mySQL 5.0.0...
5
by: smatta | last post by:
I have just installed MySql version 5.0-18 on Red Hat Fedora Core 4. It is running but I cant connect to it using MySql Query Browser running on my pc. >From my pc, I can telnet to the sql...
4
by: berry | last post by:
Hi guys... Can anyone tell me that whether SQL server or MySQL server is easier to connect and write the code in VB6? What is the advantage and disadvantages in these servers? Thank you!
6
by: markodilore | last post by:
Hey Guys, you helped me once when I tryied to create a database : "Access denied for user ''@'localhost' ". On my Mac OS 10.4, I had no problem creating database and modifying it from the terminal....
5
by: suma | last post by:
hi to all plaese help me i have same problem when download the phpdev and phptriad i cant connect to mysql when click the MyAdmin apear this messege in the page 'Warning: MySQL Connection...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.