title: Getting "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'" error when setting up mysql database for Ruby on Rails app
body: <p>I have been working on this all day long, and I need some help. </p>
  
  <p>I am trying to setup the mysql database for a RoR project I'm working on from github. </p>
  
  <p>When I try to setup the db in the terminal, I get the following error:</p>
  
  <pre><code>Eric-MacBook:~ eric$ cd ~/review_rocket
  Eric-MacBook:review_rocket eric$ rake db:setup
  Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
  </code></pre>
  
  <p>I have looked through 20 questions on SO, and none have been able to help me solve my problem. </p>
  
  <p>The database is up and running, and the database.yml is set up too.</p>
  
  <p>I am currently going a little mad... please... help...before it's too late.</p>
  
  <p>UPDATE: I just looked at my installed gems, and for some reason it's showing <code>mysql2</code> (see below)</p>
  
  <pre><code>Eric-Reas-MacBook:~ ericrea$ gem list
  
  *** LOCAL GEMS ***
  
  multi_json (1.8.2)
  mysql2 (0.3.13)
  net-sftp (2.1.2) 
  </code></pre>
  
  <p>That seems a little odd to me...</p>
  
  <p>Update: Here is what my database.yml is looking like:</p>
  
  <pre><code>common: &amp;common
    adapter: mysql2
    encoding: utf8
    reconnect: false
    pool: 5
    user_name: xxxx
    password: xxxx
    socket: /var/run/mysqld/mysqld.sock
  
  development:
    &lt;&lt;: *common
    database: dev_review_rocket
  
  # Warning: The database defined as "money_tracker_test" will be erased and
  # re-generated from your development database when you run "rake".
  # Do not set this db to the same as development or production.
  test:
    &lt;&lt;: *common
    database: test_review_rocket
  
  production:
    &lt;&lt;: *common
    database: prod_review_rocket
  </code></pre>
  
  <p>UPDATE: Now getting weird errors when trying to reinstall mysql with homebrew (see below):</p>
  
  <pre><code>$ brew install mysql
  ==&gt; Downloading https://downloads.sf.net/project/machomebrew/Bottles/mysql-5.6.1
  Already downloaded: /Library/Caches/Homebrew/mysql-5.6.13.mountain_lion.bottle.1.tar.gz
  ==&gt; Pouring mysql-5.6.13.mountain_lion.bottle.1.tar.gz
  ==&gt; /usr/local/Cellar/mysql/5.6.13/bin/mysql_install_db --verbose --user=ericrea
  2013-10-22 18:32:41 56901 [Note] InnoDB: FTS optimize thread exiting.
  2013-10-22 18:32:41 56901 [Note] InnoDB: Starting shutdown...
  2013-10-22 18:32:42 56901 [Note] InnoDB: Shutdown completed; log sequence number 1626067
  2013-10-22 18:32:42 56901 [Note] /usr/local/Cellar/mysql/5.6.13/bin/mysqld: Shutdown complete
  
  Warning: mysql post_install failed. Rerun with `brew postinstall mysql`.
  ==&gt; Caveats
  A "/etc/my.cnf" from another install may interfere with a Homebrew-built
  server starting up correctly.
  
  To connect:
      mysql -uroot
  
  To have launchd start mysql at login:
      ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
  Then to load mysql now:
      launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
  Or, if you don't want/need launchctl, you can just run:
      mysql.server start
  ==&gt; Summary
    /usr/local/Cellar/mysql/5.6.13: 9382 files, 354M
  Eric-Reas-MacBook:~ ericrea$ brew postinstall mysql
  ==&gt; /usr/local/Cellar/mysql/5.6.13/bin/mysql_install_db --verbose --user=ericrea
  2013-10-22 18:33:22 57135 [Note] InnoDB: FTS optimize thread exiting.
  2013-10-22 18:33:22 57135 [Note] InnoDB: Starting shutdown...
  2013-10-22 18:33:23 57135 [Note] InnoDB: Shutdown completed; log sequence number 1626087
  2013-10-22 18:33:23 57135 [Note] /usr/local/Cellar/mysql/5.6.13/bin/mysqld: Shutdown complete
  
  
  READ THIS: https://github.com/mxcl/homebrew/wiki/troubleshooting
  
  These open issues may also help:
      https://github.com/mxcl/homebrew/issues/22021
      https://github.com/mxcl/homebrew/pull/22480
  </code></pre>