0
votes

I'm pretty sure that this has to do with my setup but let me lay it out first. I have installed XAMPP on my machine for my LAMP projects. I'd also like to do a little Rails development for fun (RubyMine looks pretty sweet). I've installed Homebrew and the required gems to get my app running but when I try to connect to mysql via RubyMine I get the following error

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

Using my bash console I can get to the mysql console well enough, it seems to be working well and my Apache projects are still connecting. I'm under the impressions that the gem i've installed or exactly where my Ruby installation is looking is a different MySQL installation? Is this possible? I've been beating my head against my keyboard for the last day and a half and I'm not quite sure where to go. Ideally if there is a way I can point my Rails application to the installation of MySQL in my XAMPP folder that would be super cool but I'm a newb and maybe these things aren't "correct". Any help is greatly apprecited, if you guys want more info lemme know! Thanks!

Full Error:

/Users/Username/.rvm/rubies/ruby-1.9.3-p194/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/Username/.rvm/gems/ruby-1.9.3-p194@global/bin/rake db:setup Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "reconnect"=>false, "database"=>"project_development", "pool"=>5, "username"=>"root", "password"=>"mypass", "host"=>"localhost"}, charset: , collation: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "reconnect"=>false, "database"=>"project_development", "pool"=>5, "username"=>"root", "password"=>nil, "host"=>"localhost"}, charset: , collation: rake aborted! Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Tasks: TOP => db:schema:load => environment (See full trace by running task with --trace)

Process finished with exit code 1

1
Your sock file could be in your datadir instead of /tmp. There's likely a config parameter in your my.cnf that's being read when you connect through bash but not through RubyMine. I'm not familiar with RubyMine but you'll want to either look into a way to specify the sock file location or force it to connect by ip:port instead of directly through the sock.Kadaan

1 Answers

4
votes

If you run mysql in shell and then run

mysql> STATUS;

you will see a line like

UNIX socket:        /tmp/mysql.sock

This is the socket location for MySQL. You can specify this in your config/database.yml for the connection you're using with

socket: /tmp/mysql.sock

This tells Rails the socket location to connect to MySQL through.