データベースに接続しようとしていますが、localhost の代わりに 127.0.0.1 を使用するとエラーが発生します。
Warning: mysqli::mysqli(): (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
127.0.0.1 の代わりに localhost を使用すると、正常に動作します。誰でもこれについて何か洞察がありますか?
接続に使用されるコードは
<?php
$db = new mysqli('127.0.0.1', 'root', '', 'dbname');
?>