4

So I've got a Ruby on Rails application that I am trying to run (in development) on Snow Leopard. I've got it working on my Ubuntu computer, but now I need to get my Snow Leopard environment set up.

Originally, I installed the MySQL 2.8.1 Ruby Gem and was running into this issue:

uninitialized constant MysqlCompat::MysqlRes

But thanks to this tutorial I was able to resolve it by running this command and installing a previous version of the Gem:

export ARCHFLAGS="-arch i386 -arch x86_64" ;sudo gem install --no-rdoc --no-ri -v=2.7 mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config

Now that I've resolved that issue, I'm running into a different error:

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

This happens when I try to run rake db:migrate as well as when the server is running. How can I resolve this issue?

2 Answers 2

5

The reason you are running into this error is because the database.yml config file of your rails application is specifying the location of the socket.

development:
  adapter: mysql
  encoding: utf8
  reconnect: false
  database: myapp_development
  pool: 5
  username: root
  password:
  socket: /var/run/mysqld/mysqld.sock

Since your Ubuntu MySQL Socket is in a different location than your Snow Leopard MySQL Socket, you will have to create a symlink if you want to be able to share the same config file among different computers.

sudo ln -s /tmp/mysql.sock /var/run/mysqld/mysqld.sock

Note: I had to create the mysqld directory before I could put a symlink in it.

1
  • 1
    Thanks for sharing your solution. Note that you can in fact accept your own answer.
    – Arjan
    Mar 26, 2010 at 6:12
0

Check /tmp/mysql.sock.

1
  • And how does one decide what to do with it? Jul 13, 2012 at 15:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .