Sadar Ali Sadar Ali - 6 months ago 52
MySQL Question

Rails Server Error

I installed rails on mac using Homebrew recently. I fired up the rails server using

rails s
but when I visit
, I get the following error .

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

socket = socket.to_s unless socket.nil?

connect user, pass, host, port, database, socket, flags

def self.default_query_options

I have googled enough but couldn't find a solution.


I started mysql using mysql.server start . It started. But when I use
mysql -u root
, it gives the following error
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
. But in
it gives this error
Access denied for user 'root'@'localhost' (using password: NO)
. And as far as I can remember, I didn't set any password for mysql .


If your terminal gives ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES), then you definitely have a password in place. You have probably forgotten it . Also, go to config/database.yml file and fill in your mysql username and password there if you remember.

Also, if you still dont get your password; uninstall using brew remove mysql and try the .dmg installer from oracle website.