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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.