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 trial

Ruby ActiveRecord Basics Migrations and Relationships Looking at our Application

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

I downloaded the updated project files but am now have Mysql problems.

I have no idea how to fix this.

Any thoughts?

Maciej Czuchnowski is good with databases!

Steve.

7 Answers

Got there in the end. No idea what I did and I don't have any data now; just a database.

I ran a mysqld command which did something it didn't before. Then the rails app was throwing a 'unknown database'. I ran rake db:create then rake db:migrate and after fixing a few errors in the code preventing the migration, we're up and running!

I have no idea what changed - but at least I can continue with the course now! \o/

Serously, though, don't be getting students to just download the new project files - that really doesn't work too well!

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Hahaha...hardly. And I hate MySQL with all my heart and I have no idea why this course uses it. I always had problems with MySQL in Rails, so I just stopped using it.

You should probably start with your config/database.yml configuration file - make sure it uses username and password that has access to MySQL, that databases mentioned in that file are created etc.

The link describes my issue pretty much perfectly.

I can't do the suggested mysql server command as console doesn't understand the mysql command:

irb(main):001:0> mysql NameError: undefined local variable or method `mysql' for main:Object from (irb):1

Trying the rest of the suggested command has similar results:

irb(main):002:0> mysql.server start NameError: undefined local variable or method `mysql' for main:Object from (irb):2

I just downloaded a whole new project. Maybe I needed to dismantle the previous one. I've got a Github repo set up. Should I (not that I know how to) rollback to the code that worked, i.e. pre the total replacement, and drop the databases out?

Is the teacher on here ... maybe there's a slick way of achieving this, Hampton Catlin ?

Steve.

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

Hey, you are inside the irb session. You should run mysql through your terminal, exit the irb.

Path issues prevent me from using the mysql command in terminal:

/Users/stevehunter/.rbenv/shims:/Users/stevehunter/.rbenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin - I need to append /usr/local/mysql/bin to that and I don't know how.

I restarted/started the server through System Preferences - there's a MySql graphical assistant. I now get:

Steves-MBP:biller stevehunter$ rails s /Users/stevehunter/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activesupport-4.0.3/lib/active_support/values/time_zone.rb:282: warning: circular argument reference - now => Booting WEBrick => Rails 4.0.3 application starting in development on http://0.0.0.0:3000 => Run `rails server -h` for more startup options => Ctrl-C to shutdown server [2015-04-26 19:25:07] INFO WEBrick 1.3.1 [2015-04-26 19:25:07] INFO ruby 2.2.1 (2015-02-26) [x86_64-darwin14] Exiting /Users/stevehunter/.rbenv/versions/2.2.1/lib/ruby/2.2.0/socket.rb:206:in `bind': Address already in use - bind(2) for 0.0.0.0:3000 (Errno::EADDRINUSE)

Somethings already in use. I'll try stopping that server and leaving it like that.

Steve.

Exactly the same error doing that ... so I'm probably not changing the right database.

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

The "Address already in use" could mean that the server was not properly closed and you should try restarting your system to see if this still pops up. It's a Macbook Pro, right? You'd have to read more about how rbenv works and how to add things to your path. It will probably involve modifying files with names like .bash or .profile or something similar.

I had a go at all of that but I'm still stuck with the same issues.

I'll try another restart ....

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

I know how it feels and I wish I could give you a solution, but I literally gave up on mysql because all this stuff and never exercised things from this course on my machine, I only watched the videos and did the challenges.

Shutting down never seems to start from scratch. All the same windows and applications come back. How do I force a clean ground-up shut down and startup?

Searching, constantly, for this issue there's mention of all sorts of possible solutions. None make any sense to me, unfortunately!

I may do as you did and give up on the course - that's a shame.

Perhaps one last uninstall/reinstall of mysql, rails etc. Any tips on how to accomplish that?

Partial fix - I ran sudo /usr/local/mysql/support-files/mysql.server start which seems to have got the basic stuff running.

It's difficult to test as I don't know what's supposed to do what given the app has been amended!

Nope. It only partially worked.

The new database wasn't there so there were no new accounts.

I'm going to start from scratch but have no idea how to uninstall rails and/or mysql.

Reinstalled with Homebrew. No joy.

Give up! Hampton Catlin - can you post something on how to incorporate the modified files into the project, or how to avoid any conflicts?