Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGary Insley
14,133 PointsMysql2::Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) - (ActiveRecord Basics Course)
My biller app was working fine and i was following along with Hampton's Active Record Course, however today i have tried to start the IRB and work with the ruby programme again but i am getting the following error when trying to access any model within my app.
Mysql2::Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
I have googled the problem and tried to follow along to their suggestions, however none seem to work.
This is my CONFIG> Database.yml file...
default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: root
password:
host: localhost
development..... (etc - this part all looks fine)
Some forums have said i need to add socket: socketlocation to the above table. I have tried adding various addresses, but im also unsure as if i have this file on my system, have been unable to find it.
Everything was working before i pulled and then pushed my project to my git hub repository, would this of cause any problems in anyway???
Thanks for your help...
Samuel Allemang
28,116 PointsSamuel Allemang
28,116 PointsHi Gary,
I'm very new to this, but here's what worked for me:
I resumed the course at the 'Relationships' lesson after a few days and had the same error. In my case, it was simply* a matter of restarting the server. In Terminal, within your project folder (
Projects/biller
for me), prior to starting your Rails console withrails c
, restart your MySQL server withmysql.server start
.Hope that works for you. I don't pretend to really understand what's going on here; all I know is it worked!
*I say 'simply', when what I really mean is I Googled and Googled until I found the answer.