Strange 5 second pause with PHP command line interface (related to mysql/mysqli extension)

前端 未结 4 2035
独厮守ぢ
独厮守ぢ 2021-01-05 11:50

I\'m getting a strange 5 to 7 second pause when executing PHP scripts from the command-line PHP client (PHP 5.2 on Windows).

During this pause the PHP script just ap

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-05 12:04

    On linux in 2020 with PHP 7.4 this still happens. The solution was to link my hostname to 127.0.0.1 in the /etc/hosts file, so the 5 second delay was from looking up my own hostname (and not finding it). While on servers I have set up the hostnames, I didn't really do that on my desktop systems (and it does not do that automatically).

    To solve it, run hostname on the command line (to see the hostname of the current machine) and then add this line to /etc/hosts:

    127.0.0.1 yourhostname
    

    Where you would replace yourhostname with what hostname showed you.

提交回复
热议问题