2

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
4
  • 1
    if you are as lazy as I am, you may consider XAMPP on Mac as a good all-in-one package of MAMP :) Commented Oct 18, 2010 at 22:31
  • 1
    No solution, but maybe an easier alternative: MAMP: Mac, Apache, MySQL, PHP Commented Oct 18, 2010 at 22:31
  • @Michael Thanks for that! Although I'm not lazy (well, never-mind!), just overwhelmed by the massive amounts of sudoing and terminal commands necessary for all of this to work just right. Thanks for the sample @Alec Commented Oct 18, 2010 at 22:34
  • Also, just wondering, does it matter if I already installed PHP and partially installed MySQL? Commented Oct 18, 2010 at 22:36

3 Answers 3

6

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

Sign up to request clarification or add additional context in comments.

4 Comments

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 yup, 127.0.0.1 can still be correct. It's probably somewhere in the E-Commerce system's settings
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 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
2

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.

Comments

2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.