动态数据PHP错误[重复]

动态数据PHP错误[重复]

问题描述:

This question already has an answer here:

I'm a inexperienced webmaster for my Boy Scout troop. I have recently set up MAMP on my map and then tried to use MySQL PHP server for dynamic data. When testing locally, everything worked. When I uploaded everything to my web server (for which I only have FTP access) I get this message when I try to access the php page.

Fatal error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in 

Can anyone tell me what I'm doing wrong?

More info:

  • Mac Pro 1,1 running 10.7
  • Dreamweaver CS6
  • MySQL Server 5.3.3
</div>

此问题已经存在 这里有一个答案: p>

  • 无法通过套接字'/var/mysql/mysql.sock'连接到本地MySQL服务器(38) 38 answers span> li> ul> div>

    我是一名没有经验的童子军队长。 我最近在我的地图上设置了MAMP,然后尝试使用MySQL PHP服务器来获取动态数据。 在本地测试时,一切正常。 当我将所有内容上传到我的Web服务器(我只有FTP访问权限)时,当我尝试访问php页面时,我收到此消息。 p>

     致命错误:无法通过套接字'/var/lib/mysql/mysql.sock'(2)连接到本地MySQL服务器
      code>  
     
     

    谁能告诉我我做错了什么? p>

    更多信息: p>

    • Mac Pro 1,1运行10.7 li>
    • Dreamweaver CS6 li>
    • MySQL Server 5.3.3 li> ul> div>

I solved this problem. My error was that I didn't have MAMP set up to allow connections from the outside. Google it, there are many good resources out there to help you set it up. After I did that and made sure root access from any IP was enabled, I was good to go. Thanks for everyones help.

IF you are sure that the server is UP and MySQL is running, the following may be true:

When MySQL states it is trying to connect through a local socket, this typically means you are using "localhost" as the address for the MySQL server in your PHP code.

Instead try using the IP Address of the MySQL server.

If this does not fix the problem, then make sure your mysql user that your code is using has permissions to access the MySQL server from 'localhost'.

Let me know if you have any questions about any of this.