# Cannot connect to local MySQL server

**URL:** <https://forum.kirupa.com/t/cannot-connect-to-local-mysql-server/211371>\
**Category:** Uncategorized\
**Created:** [December 30, 2006, 9:07pm UTC](https://forum.kirupa.com/t/cannot-connect-to-local-mysql-server/211371 "2006-12-30T21:07:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stuluk28](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/stuluk28/32/2775_2.png) [@stuluk28](https://forum.kirupa.com/u/stuluk28)\
**Post date:** [December 30, 2006, 9:07pm UTC](https://forum.kirupa.com/t/cannot-connect-to-local-mysql-server/211371/1 "2006-12-30T21:07:25Z")

</div>

Hey I’m having some seriously frustrating problems trying to get things sorted so I can develop php and mySQL websites locally for testing.

I’m running Mac OS X 10.4.8  
PHP 4.4.4  
MySQL 4.1.22-max  
Apache 1.3.3  
phpMyAdmin 2.9.1.1

Basically, PHP is running fine, and I’ve setup and played around with a database through terminal and through phpMyAdmin. But when I try to connect to the database with a PHP it returns an error EVERY TIME!  
//----------  
\<?php  
$connect = mysql\_connect(‘localhost’, ‘user’, ‘password’);  
?\>

returns this error in the browser:

Warning: mysql\_connect() [function.mysql\_connect]: Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’ (2) in /Users/One80Admin/lukesturgeon.co.uk/dev/inc/connect.php on line 2  
//----------

If you’ve got any thoughts I’d really appreciate it. I’m sure it’s something really simple and obvious.

Could it be to do with the sockets? I have a problem with phpMyAdmin initially until I specifed the path to the socket???
