views:

61

answers:

3

I know this sounds a little ridiculous, but I'm just honestly wondering how I can create a MySQL database on my Mac OS X machine. I have MySQL installed (as far as I know) as well as PHP, and I'm wondering how I can create one.

I have downloaded a sample PHP ecommerce site to kind of delve into what I'm trying to familiarze myself with, and the PHP files are attempting to connect to a nonexistant database, which I'm hoping to create right now.

Do they have an extension of .sock? Because, here is the "error" code when I try to test a PHP page referencing the nonexistant database:

Warning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in< /Library/WebServer/Documents/plaincart/library/database.php on line 4 Warning: mysql_connect(): No such file or directory in
/Library/WebServer/Documents/plaincart/library/database.php on line 4 MySQL connect failed. No such file or directory
+2  A: 

My guess is you are specifying the database server as localhost somewhere. Try 127.0.0.1 instead.

Pekka
I can't seem to find it, but I'm still checking, also, I'm trying this out on my `localhost` if that makes a difference.
BOSS
@BOSS yup, 127.0.0.1 can still be correct. It's probably somewhere in the E-Commerce system's settings
Pekka
Hmm, just saying, I ran this through XAMPP on my Mac, and got this now: `Cannot select database. Unknown database 'phpwebco_shop'`. Wondering if it's still the sample problem, considering I don't have a database yet.
BOSS
@BOSS nope - it's solved, you are now talking to your database. That is a new issue, you'll probably need to set up a database for the E-Commerce package. The installation instructions should help you there
Pekka
Thanks! Awesome.
BOSS
+1  A: 

I had this problem once with WordPres on Mac OS X. The answer was to name the local machine in the db connection configuration 'Localhost' with capital 'L', because on OS X localhost != Localhost.

ofi
+2  A: 

I had the same problem with MySQL on the OSX. It turned out that the MySQL server was actually set up to use a different socket than the default setting in PHP.

PHP was looking in /var/mysql/mysql.sock, while mysql was creating the socket in /tmp/mysql.sock.

I fixed it by editing the php.ini and set mysql.default_socket = /tmp/mysql.sock

CodeTwice