Mysql Database connection Error

Hi , i am new to ruby, i seem to have a problem connecting to my mysql
database, i keep getting this error, {Error code:
2002
Error message: Can’t connect to local MySQL server through socket
‘/var/run/mysqld/mysqld.sock’ (2)}

  • i use ubuntu 12.04.
    please assist!
  1. Did you install ‘the mysql database server’? That isn’t the same
    thing as the mysql2 ruby gem. The mysql2 ruby gem just allows
    your ruby code to talk to ‘the mysql database server’. To
    download ‘the mysql database server’ go here:

http://dev.mysql.com/downloads/

You want to download the free community version.

  1. If you already installed ‘the mysql database server’, then you have
    to start it before running your ruby program. Once again, the mysql2
    ruby gem just allows you to talk to ‘the mysql database server’. If
    there is no one on the other end of the phone, your ruby program has no
    one to talk to. To start ‘the mysql database server’, check the README
    file. Mine contains these instructions:

For startup:

 shell> cd /usr/local/mysql
 shell> sudo ./bin/mysqld_safe
 (ENTER YOUR PASSWORD, IF NECESSARY)
 (PRESS CONTROL-Z)
 shell> bg
 (PRESS CONTROL-D OR ENTER "EXIT" TO EXIT THE SHELL)

SHUTDOWN:
$ cd /usr/local/mysql
$ sudo mysqladmin shutdown

If I run a ruby mysql program without starting ‘the mysql database
server’ beforehand, I get the following error:

/Users/7stud/.rvm/gems/[email protected]/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in
`connect’: Can’t connect to local MySQL server through socket
‘/tmp/mysql.sock’ (2) (Mysql2::Error)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs