How to solve – Can’t connect to MySQL server on ‘localhost

Yesterday I started developing a site using Ruby On Rails with MySQL database.

When I tried to connect to MySQL I got error message

The funny part is that I was able to connect to mysql by using its command line client:

Solution:

Instead of trying to connect to localhost, connect to 127.0.0.1.

In case of Rails, do the following:

open the file

and edit the lines

so that they will look like

Save the file and you’re done.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *