Topic: how to change rails mysql socket PATH from /var/run to /var/lib?

i have an app im installing that tries look for mysqld.sock in /var/run/mysqld/mysqld.sock and mysql puts it at  /var/lib/mysql/mysql.sock. if i point mysql at /var/run the app works i.e start it like so: mysqld -socket=/var/run/mysqld/mysqld.sock; if i don't i get an error that goes " Showing app/views/articles/index.rhtml where line #35 raised:

No such file or directory - /var/run/mysqld/mysqld.sock". like i said i can get around this "manually" but i'd rather have them looking in the same place by default. so, anyone know where i change that?

Re: how to change rails mysql socket PATH from /var/run to /var/lib?

You'll need to edit the config/database.yml in your Rails application directory to look something like this:

development:
  adaptor: mysql
  database: your_database
  username: foo
  password: bar
  socket: ~path to your sock~

Or you could bypass the socket and go with a configuration like this:
development:
  adaptor: mysql
  database: your_database
  username: foo
  password: bar
  host: localhost
  # and if needed us this following line
  port: 3306

Most code examples are usually pulled out of the air and not tested. Use at your own risk!

Re: how to change rails mysql socket PATH from /var/run to /var/lib?

sweet. thanks much

Re: how to change rails mysql socket PATH from /var/run to /var/lib?

I recommend using the following database.yml file:

login: &login
  adapter:  mysql
  username: user
  password:
  socket:  <%=
    ['/opt/local/var/run/mysql5/mysqld.sock', # darwinports
     '/opt/local/var/run/mysqld/mysqld.sock', # darwinports, again
     '/var/run/mysqld/mysqld.sock',           # ubuntu/debian
     '/tmp/mysql.sock'].select { |f| File.exist? f }.first %>

development:
  <<: *login
  database: rails_development

test:
  <<: *login
  database: rails_test

production:
  <<: *login
  database: rails


(source)

Last edited by danger (2006-08-02 20:09:26)