1
0

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.

RSpecでテストしたときに、MySQLに接続できないよ!というエラーがでたら

1
Last updated at Posted at 2019-10-10

はじめに

RSpecでテストしたいけど、Mysql2::Error::ConnectionError: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)というエラーがでて、テストできない(汗)という経験がありましたので、解決策をまとめてみました。

環境

・MacOS High Sierra バージョン10.13.4
・RSpec 3.8
・MySQL Ver 8.0.17 for osx10.13 on x86_64 (Homebrew)

ターミナルでrspecと入力したら、エラーがでた

エラーメッセージ
Mysql2::Error::ConnectionError: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

◆解決方法

1、sudo mysql.server startを入力
2、パスワードを求められるので、管理者パスワードを入力
3、Starting MySQL SUCCESS!とでれば成功です。

おわりに

ぼくの場合、mysql.server startをしても、ずっとエラーになってMySQLが起動できず、調べても調べても解決策が見つからないときがありました。
そんなときにsudoを追加すればいいと知ったときは、目からウロコでした。

参考

MySQL 8.0 Reference Manual_4.3.3 mysql.server — MySQL Server Startup Script
Apple_ターミナルでのコマンドの使い方。(超初心者向け)_sudoコマンド

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?