hetare
@hetare

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

Mysql2::Error::ConnectionError: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

解決したいこと

この記事 https://qiita.com/tsubasaozawa/items/98f3e64a450d4304fc84 
を参考に
scaffoldを使ってアプリを作って見ようとしたら

rake db:create を打ったあとに下記のエラーが発生しました。

発生している問題・エラー

warning: Using the last argument as keyword parameters is deprecated
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Couldn't create 'todo_list_development' database. Please check your configuration.
rake aborted!
ActiveRecord::ConnectionNotEstablished: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)


Caused by:
Mysql2::Error::ConnectionError: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

自分で試したこと

この記事 https://qiita.com/tkmd35/items/c26d1dffca4be0a4f017 
をもとに
こちらの原因1、2のところを実行してみましたが、
同じエラーがまた出るだけで解決できませんでした。

お教えいただけたら幸いです。

0

1Answer

Possible solutions

1) Start MySQL server on the local machine if not already running

Linux

sudo systemctl start mysqld

OR

sudo systemctl start mariadb

2) If MySQL server is not on the local machine, give appropriate host configuration in the application

1Like

Your answer might help someone💌