PHP - MYSQL - test database server

前端 未结 3 1948
遇见更好的自我
遇见更好的自我 2020-12-09 23:51

I\'m learning PHP MYSQL and trying to create a database.

I\'m following this tutorial http://www.raywenderlich.com/2941/how-to-write-a-simple-phpmysql-web-service-f

相关标签:
3条回答
  • 2020-12-09 23:51

    There are two settings you have to check for this to work (assuming you have MySQL server installed of course):

    Check the value of mysql.default_socket in your PHP configuration.

    Check the value of socket in your MySQL configuration file under the [mysqld] heading.

    Those values have to be identical; if they're not, change one to match the other and restart respective service.

    0 讨论(0)
  • 2020-12-09 23:59

    Apache servers use '127.0.0.1' instead of 'localhost'

    0 讨论(0)
  • 2020-12-10 00:01

    This seems to be a common issue, as googling for it yields quite a few results. I experienced this on my two linux boxes as well (never under Windows though) and at some point I resolved to just use 127.0.0.1 on all dev servers. Basically, localhost makes the connection to the MySQL server use a socket, but your configuration doesn't point to the socket file correctly.

    Here are a couple of resources that you might find useful:

    http://westsworld.dk/blog/2011/03/problems-connecting-to-unixvarmysqlmysql-sock/ - basically what @Jack suggests, but more in depth

    Can't connect to MySQL on Mac -- missing mysql.sock file - here's how to locate your socket file (for some reason, my php.ini had the path wrong, and I assume your case could be similar).

    I hope this helps.

    0 讨论(0)
提交回复
热议问题