473,703 Members | 2,221 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2629
sc***********@g ooglemail.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*******@attgl obal.net
=============== ===

Apr 8 '08 #2
On Apr 8, 9:37 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
scorpionbi...@g ooglemail.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...@attgl obal.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...@g ooglemail.com wrote:
On Apr 8, 9:37 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
scorpionbi...@g ooglemail.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...@attgl obal.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...@g ooglemail.com wrote:
On Apr 8, 9:47 pm, scorpionbi...@g ooglemail.com wrote:
On Apr 8, 9:37 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
scorpionbi...@g ooglemail.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...@attgl obal.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***********@g ooglemail.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*******@free mail.ru>

Jun 27 '08 #6

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

Similar topics

0
9008
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 to connect from a remote location using: mysql -h xxx.xxx.xxx.xxx -P 3306 -u root -p mysql I get: ERROR 2003: Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (10061) When I try:
0
3290
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" all afternoon and it seems to have something to do with the "mysql_install_db" not being installed correctly -- I have tried multiple installs with multiple downloaws. My log. . .
0
2329
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 "/usr/bin/mysqld_safe --skip-grant-tables &" I show several mysqld procs. and one mysqld_safe, but I can't connect: # ps -aux| grep mysql Warning: bad syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html root 3650 0.0 0.1 2276 664 ? S ...
2
1546
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 $ ./scripts/mysql_install_db I have a user mysql, and group mysql. I ran
1
121532
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 alpha) so I deinstall mysql5-server and mysql5-client And then I install mysql41-server and mysql41-client on FreeBSD 5.3 by ports but now , mysql is not workable
5
5089
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 server / port. I get back a garbled message: 5.0.18-standard§}WxyuadT,☻V6F?J5i1YMT= Should this be garbled ? or is there a problem ?
4
1419
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
6322
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. But I use Dreamweaver 8 to connect to MySQL, with its built-in feature "MySQL Connection" I write this: Connection Name: con_test001 MySQL Server: localhost User Name: root Password: 55555 Database: test001 (which is a database I already...
5
2947
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 Failed: Can't connect to MySQL server on 'localhost' (10061) in C:\apache\htdocs\phpmyadmin\lib.inc.php on line 255"
0
8658
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9096
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8993
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8947
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7842
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6583
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4674
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2419
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2049
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.