Using Docker I get the error: “SQLSTATE[HY000] [2002] No such file or directory”

后端 未结 3 1824
一个人的身影
一个人的身影 2020-12-07 20:59

I\'m using Docker to create a container to test my web app built on PHP and MySQL on my Mac. My PHP app is built using Fat-Free Framework for MVC and routing. I have two D

3条回答
  •  北海茫月
    2020-12-07 21:24

    php lives on a different docker image than mysql. thus localhost and 127.0.0.1 from php do not point to mysql. you should connect to the ip of the mysql docker instance.

    also make sure mysql is listening on all interfaces. In mysql.ini you need to put listen 0.0.0.0 to listen on all available interfaces. By default it only allow connections from localhost (and the php docker container is a different host).

提交回复
热议问题