0

I'm trying to install Concrete5 on a localhost using MAMP, but every time I put it the database information, I get this error.

SQLSTATE[HY000] [2002] No such file or directory

How can I solve this problem?

kriskendall99
  • 547
  • 1
  • 4
  • 14

4 Answers4

0

Error 2002 is typically displayed as

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/path/to/mysqld/mysqld.sock'

PHP can't connect to MySQL using a socket. On windows you probably don't want to use unix socket.

"But I'm not using unix sockets, I'm simply connecting to localhost" you might say.

For the PHP driver 'localhost' has a special meaning as described in the PHP manual.

The hostname localhost has a special meaning. It is bound to the use of Unix domain sockets. It is not possible to open a TCP/IP connection using the hostname localhost you must use 127.0.0.1 instead.

Solution: configure 127.0.0.1 as your MySQL host for Concrete5.

Arnold Daniels
  • 16,516
  • 4
  • 53
  • 82
0

I finally solved this problem. I went into MAMP and found the MySQL port number and typed into the server box in this format: localhost:[MySQL Port].

kriskendall99
  • 547
  • 1
  • 4
  • 14
0

Try 127.0.0.1:[MySQL port], that did the trick for me.

To find your port number, go to the MySQL section in MAMP and look at the top right corner of the screen. There will be a message saying: MySQL is configured to use port [port number].

Syden
  • 8,425
  • 5
  • 26
  • 45
0

I did it on MacOS 10.13 and MAMP 5.1, create a symlink to mysql.sock in /var/mysql (create the directory if it does not exist).

It's solution works global, without change any config, so PHP can connect to MySQL.

Type it in console/terminal:

sudo mkdir /var/mysql
cd /var/mysql && sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock
Zlocorp
  • 314
  • 3
  • 4