LoginSignup
1
1

More than 5 years have passed since last update.

Bash on WindowsからローカルのMySQLサーバに接続できないと思ったら

Posted at

現象

Windows版MySQL_serverがすでにインストールされている環境で, bashからローカルのMySQLサーバに接続できない

対応

mysql -u root -p

ではなく

mysql -u root -p -h 127.0.0.1

とホストを明示的に指定してアクセスする

問題の原因

ホストとしてlocalhostを指定した場合(あるいはホストの指定を省略した場合), mysqlのクライアントは

mysql.sockを使ってサーバとの通信を行おうとするが. windows環境では当然そんなソケットファイルは存在しないので

接続エラーになるようです.

参考

UNIXドメインソケット : https://ja.wikipedia.org/wiki/UNIX%E3%83%89%E3%83%A1%E3%82%A4%E3%83%B3%E3%82%BD%E3%82%B1%E3%83%83%E3%83%88

1
1
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
1
1