17
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[php]mysqliでNo such file or directoryが出る

Posted at

phpのmysqliでDB接続を試みたところ、
[No such file or directory]とか出てくる。

google先生に質問してみたところいっぱい出てきた。
php.ini か my.conf のmysql.sock の場所を指定してあげれば良いらしい。

[mysql.sockの場所を確認]
$mysqladmin -u name -p version

Server version 5.6.14
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /tmp/mysql.sock ←ここ
Uptime: 1 day 12 hours 30 min 23 sec

[php.ini]上のUNIX socketに書き換え
pdo_mysql.default_socket = /tmp/mysql.sock
mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock

でNo such云々は出なくなったけどDBから結果をとれなくて

$mysqli = new mysqli("localhost", "name", "pass", "test");

$mysqli = new mysqli("127.0.0.1", "name", "pass", "test");
に変更したらうまい事いった。
わーい。

17
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?