When I use my Mac to continue developing my Rails application using Mysql as the database system. It first initialized and developed in Ubuntu.
After bundling tasks, I move to rake db:create to initialize my databases for development and test environment. But the problem comes out:
Mysql2::Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
Ok, cd to the
Oh, there’s no mysqld.sock there. Ok so there must be error as above error message.
So, I was wondering where is mysqld.sock in my computer? I was installed Mysql through brew and able to connect to Mysql by Mysql Workbench with no problem. So let’s see some variables. Enter to the terminal:
mysqladmin -p variables | grep socket
Provide password, and then you will see something like:
| performance_schema_max_socket_classes | 10 | performance_schema_max_socket_instances | -1 | socket | /tmp/mysql.sock|
Wow, there comes in the socket line the mysql.sock file location
We have to connect through it.
After some research, I know that Rails settings the socket in database.yml file.
So, it’s ez now, just replace the new found path.
It’s ok now. I can continue my work.