The Passionate Craftsman

Ruby, PHP, MySql, Software engineering and more.

Friday 23 October 2009

How to install Mysql/Ruby on Solaris SPARC 64

I found only partial documentation on how to install the Ruby driver for MySql. There are two version of drivers, one is MySql/Ruby and is written in C, the second is Ruby/MySql and is written in Ruby. Ruby/MySql is included in Rails but has slower performance, plus it was not working with MySql 5.0, it does not work with MySql 4.something too!

So I decieded to compile the C driver. Below you can find the commands:


curl http://tmtm.org/downloads/mysql/ruby/mysql-ruby-2.7.tar.gz -o mysql-gzip -d gzip -d mysql-ruby-2.7.tar.gz
tar xfv mysql-ruby-2.7.tar
cd mysql-ruby-2.7
ruby extconf.rb --with-mysql-include=/usr/local/mysql/include/mysql --with-mysql-lib=/usr/local/mysql/lib/mysql
make
sudo make install


Make sure that 'make install' will be executed as root. Now you can test the connection with:


ruby test.rb [hostname] [username] [dbpassword]


Of course you have to put the host, username and password. Another nice script to test your MySql connection is:


require 'mysql'

mysql = Mysql.init()
mysql.connect('localhost', 'username', 'password')
results = mysql.query("SELECT now();")
results.each{|row|; puts row;}
mysql.close()

Labels: ,

3 Comments:

At 23 February 2012 at 10:50 , Anonymous Anonymous said...

how do you take the results and put them into a spreadsheet

 
At 23 February 2012 at 10:54 , Blogger Riccardo Tacconi said...

This comment has been removed by the author.

 
At 23 February 2012 at 10:58 , Blogger Riccardo Tacconi said...

Hi, I am not sure if I understand your question. What a spreadsheet has to do with this post?

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home