且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

此php代码可在localhost上运行,但不能在服务器上运行?

更新时间:2023-02-22 21:38:02

我过去遇到过类似的问题.假设您的MySQL服务器在同一盒上运行,则应尝试将localhost更改为127.0.0.1.

I have encountered similiar issues in the past. You should try changing localhost to 127.0.0.1, assuming your MySQL server is running on the same box.

我的信念是,您遇到的问题是"localhost"使用UNIX套接字,并且无法在标准目录中找到数据库.但是,"127.0.0.1"使用TCP,这实际上意味着它通过计算机上的本地Internet"运行,比UNIX套接字要可靠得多.

My belief is that the issue that you are encountering is that "localhost" uses a UNIX socket and can not find the database in the standard directory. However "127.0.0.1" uses TCP , which essentially means it runs through the "local internet" on the machine, being much more reliable than a UNIX socket.

推荐文章