Install MySQL/Ruby using the Ruby Gems packaging manager: Email: ["m", "o", "c", ".", "l", "i", "a", "m", "g", "2", "+", "T", "F", "I", "H", "S", "o", "u", "l", ".", "m", "o", "t"].reverse.join 1. Get a list all mysql packages installed on your machine. sudo dpkg -l |grep mysql 2. sudo apt-get install libmysqlclient15-dev 3. $which is mysql_config Now you should get something like this. /usr/bin/mysql_config 4. sudo gem install mysql or $sudo gem install mysql -- --with-mysql-config = /usr/bing/mysql_config Gem files will remain intsalled in /var/oib/gems/1.9.0/gems/mysql-2.8.1/ for inspection extconf.rb:1:in 'require': no such file to load - mkmf (LoadError) If you get the above error, you may have to install ruby1.8-dev or ruby1.9-dev. sudo apt-get install ruby1.8-dev sudo apt-get install ruby1.9-dev 5. ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock Run the above command if you get the error message below. sudo / -name mysqld.sock if you don't know where your sock file is. /usr/local/lib/site_ruby/1.8/mysql/protocol.rb:212:in 'initialize': No such file or directory - /tmp/mysql.sock (Errno::ENOENT) from /usr/local/lib/site_ruby/1.8/mysql/protocol.rb:212:in 'new' from /usr/local/lib/site_ruby/1.8/mysql/protocol.rb:212:in 'initialize' from /usr/lib/ruby/1.8/timeout.rb:53:in 'timeout' from /usr/local/lib/site_ruby/1.8/mysql/protocol.rb:209:in 'initialize' from /usr/local/lib/site_ruby/1.8/mysql.rb:110:in 'new' from /usr/local/lib/site_ruby/1.8/mysql.rb:110:in 'connect' from /usr/local/lib/site_ruby/1.8/mysql.rb:42:in 'connect' from mysql.rb:2 6. Example 6.1 mysql>CREATE TABLE EMP(EMP INT, ENAME VARCHAR(20)); mysql> INSERT INTO EMP(EMP,ENAME) VALUES(1,'Tom Luo'); 6.2 vi mysql.rb require 'mysql' my = Mysql.connect('localhost', 'user', 'password', 'database_name') my.query("select EMPNO,ENAME from EMP").each do |EMPno,ENAME| p EMPNO,ENAME end stmt = my.prepare('insert into EMP(EMPNO,ENAME) values (?,?)') stmt.execute 2, 'Robert Martin' 7. Test in irb irb>require 'mysql' irb>my=Mysql.connect('localhost','user','password','db_name') irb>my.query("SELECT log2(1024) FROM DUAL").each {|x| puts x} 10 irb>my.query("SELECT radians(180) FROM DUAL").each {|x| puts x} 3.14159265358979 Now you can call any MySQL functions. LOG2 is a MySQL function that is missing in Ruby. See this page for more examples. http://www.tmtm.org/en/mysql/ruby/example.html