Help us understand the problem. What is going on with this article?

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

More than 5 years have passed since last update.

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");
に変更したらうまい事いった。
わーい。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした