开发者

create mysql database on mac os x

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


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


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜