I have a standard Rails3 environment, RVM 1.2.9, Rails 3.0.5, Ruby 1.9.2p180, MySQL2 Gem 0.2.7, mysql-5.5.10-osx10.6-x86_64
Error I get when running rake db:m
On my machine mysqld service stopped that's why it was giving me the same problem.
1:- Go to terminal and type
sudo service mysqld restart
This will restart the mysqld service and create a new sock file on the required location.
The default location for the MySQL socket on Mac OS X is /var/mysql/mysql.sock
.
I have had the same problem, but none of the answers quite gave a step by step of what I needed to do. This error happens because your socket file has not been created yet. All you have to do is:
/tmp/mysql.sock
is created, to do that you run: mysql server start
config/database.yml
file and add/edit the socket: /tmp/mysql.sock
entryrake:dbmigrate
once again and everything should workout fineFound it!
Change host: localhost
in config/database.yml to host: 127.0.0.1
to make rails connect over TCP/IP instead of local socket.
development:
adapter: mysql2
host: 127.0.0.1
username: root
password: xxxx
database: xxxx
If you are on Mac OSX,
The default location for the MySQL Unix socket is different on Mac OS X and Mac OS X Server depending on the installation type you chose
MySQL Unix Socket Locations on Mac OS X by Installation Type
So just change your database.yml in socket: /tmp/mysql.sock
to point to the right place depending on what OS and installation type you are using
With my installation of MAMP on OSX the MySQL socket is located at /Applications/MAMP/tmp/mysql/mysql.sock
. I used locate mysql.sock
to find my MySQL socket location.
So my config/database.yml
looks like:
development:
adapter: mysql2
host: localhost
username: root
password: xxxx
database: xxxx
socket: /Applications/MAMP/tmp/mysql/mysql.sock