When I tried to create a database with the rails app,
$ bundle exec rake db:create
warning ../../../package.json: No license field
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Couldn't create 'hello_rails_development' database. Please check your configuration.
rake aborted!
Mysql2::Error::ConnectionError: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Error occurred.
mysql cannot be started (Can't connect to local MySQL server through socket'/tmp/mysql.sock' (2)) https://qiita.com/carotene4035/items/e00076fe3990b9178cc0 I restarted the mysql server referring to the article in.
$ sudo mysql.server restart
Password:
Sorry, try again.
Password:
Sorry, try again.
Password:
sudo: 3 incorrect password attempts
However, I was told that I needed a password, and I had forgotten my MySQL password, so I used this article as a reference to eliminate the MySQL password. (If true, you should write the password in database.yml of the rails app ...) How to reset if you forget the root password of MySQL 8.x in Mac local environment https://qiita.com/miriwo/items/1880e9d2ebcfd3c0e60d
$ mysql.server stop
$ mysqld_safe --skip-grant-tables &
$ mysql -u root
$ mysql.server status
$ kill [number]
$ ps aux| grep mysqld
$ kill [number]
$ mysql.server restart
$ bundle exec rake db:create
I was able to create the database safely.
Recommended Posts