glennfiddich Posted September 8, 2010 Share Posted September 8, 2010 2010-09-07 05:00:13 UTC When trying to create a database connection on a Mac, connecting to MySQL with PHP with the following code <?php // 1. Create a database connection $connection = mysql_connect("localhost","root","password"); if (!$connection) { die("Database connecton failed: " . mysql_error()); } ?> , I get the following warning: Warning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in /Users/username/Sites/php_sandbox/databases.php on line 3 Warning: mysql_connect(): No such file or directory in /Users/username/Sites/php_sandbox/databases.php on line 3 Database connecton failed: No such file or directory Previously, I entered the following commands on the Terminal to create a MySQL directory and soft link it to the default socket that was used to connect users-iMac:~user$ sudo mkdir /var/mysql users-iMac:~user$ sudo ln –s /tmp/mysql.sock /var/mysql/mysql.sock Any suggestions? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/212874-connecting-to-mysql-with-php-using-phpmyadmin/ Share on other sites More sharing options...
petroz Posted September 8, 2010 Share Posted September 8, 2010 Try using mamp... its free and works. Quote Link to comment https://forums.phpfreaks.com/topic/212874-connecting-to-mysql-with-php-using-phpmyadmin/#findComment-1108871 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.