I am brand-new to web development and RoR - an uber-noob! - and I'm taking an online RoR course via lynda.com. Excited to join the StackOverflow community, and would really appreciate some help with a roadblock.
MySQL and localhost were working fine for several weeks as I set up my rudimentary app and successfully ran some migrations, but today I am getting this MySQL error when I launch my rails server and view on http://localhost:3000/ in my browser:
Mysql2::Error (Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)):
I don't think I've changed anything relevant in my environment, so I wonder if I need to update gems or something simple like that?
I've hunted around on Google and StackOverflow for a couple hours now and still can't figure out what went wrong here and how to fix it. Other solutions seem to relate to new set-ups as opposed to a working set-up that inexplicably breaks.
Here's some context:
From my config/database.yml:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: simple_cms_development
pool: 5
username: simple_cms
password: XXXXXXXXX
socket: /tmp/mysql.sock
I saved a command line from a couple weeks ago when MySQL and localhost were working fine:
Last login: Mon Aug 15 21:34:23 on ttys000
sdemessieres$ cd sites/simple_cms
sdemessieres$ pwd
/Users/sdemessieres/sites/simple_cms
sdemessieres$ rails server
=> Booting WEBrick
=> Rails 3.0.7 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-08-22 22:28:01] INFO WEBrick 1.3.1
[2011-08-22 22:28:01] INFO ruby 1.8.7 (2009-06-12) [universal-darwin10.0]
[2011-08-22 22:28:01] INFO WEBrick::HTTPServer#start: pid=66952 port=3000
Started GET "/" for 127.0.0.1 at Mon Aug 22 22:28:20 -0400 2011
Processing by DemoController#index as HTML
etc... (worked fine from here)
But then today I tried the same commands and receive the error:
Last login: Mon Sep 5 12:13:22 on ttys000
sdemessieres$ cd sites/simple_cms
sdemessieres$ pwd
/Users/sdemessieres/sites/simple_cms
sdemessieres$ rails server
=> Booting WEBrick
=> Rails 3.0.7 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-09-05 12:33:09] INFO WEBrick 1.3.1
[2011-09-05 12:33:09] INFO ruby 1.8.7 (2009-06-12) [universal-darwin10.0]
[2011-09-05 12:33:09] INFO WEBrick::HTTPServer#start: pid=11027 port=3000
Started GET "/" for 127.0.0.1 at Mon Sep 05 12:33:41 -0400 2011
Mysql2::Error (Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)):
Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.0.7/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.8ms)
Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.0.7/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.7ms)
Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.0.7/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (6.3ms)
So I went back to the database notes from my training and tried connecting to MySQL from my command line which had worked before but no longer:
sdemessieres$ pwd
/Users/sdemessieres/sites/simple_cms
sdemessieres$ which mysql
/usr/local/mysql/bin/mysql
sdemessieres$ mysql --version
mysql Ver 14.14 Distrib 5.5.13, for osx10.6 (i386) using readline 5.1
sdemessieres$ mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
sdemessieres$
One StackOverflow thread gave me this clue but it only seems to reinforce that my set up is correct.
sdemessieres$ mysql_config |grep -- --socket
--socket [/tmp/mysql.sock]
As I said, I am a total beginner so any help would be much appreciated, thanks!