Jump to content

connecting to mysql with php using phpmyadmin


glennfiddich

Recommended Posts

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.