Debian Lenny - Installing MySQL (with Rails and PHP options)

We've already covered how to install MySQL on Debian Lenny, but now we need to prepare our Rails or PHP installations to make use of it.

In this article we will look at what other packages are needed for MySQL to integrate with Ruby on Rails and with a standard PHP install.


MySQL and Ruby on Rails

Assuming that you have already followed the Debian Lenny - Ruby on Rails Installation, we only have one package left to install (the MySQL Ruby Gem.)

Installing the mysql ruby gem is easy, simply run:

sudo gem install mysql

That's it! Now your rails application should be ready to use the mysql database adapter. Let's conduct a quick test using the 'irb' console to see if all is well:

irb
#irb(main):001:0> 
require 'rubygems'
=> true
#irb(main):002:0> 
require 'mysql'
=> true

Looks good! We were able to load the mysql gem just fine.

MySQL and PHP

If you installed Apache and PHP using the Debian Lenny - Apache and PHP article, you will already have the PHP MySQL module installed (which is 'php5-mysql').

This simple process also installs the PHP 'mysqli' (MySQL improved extension) module. This allows for much more powerful MySQL usage within PHP - please see the PHP mysqli page for more details.

A standard phpinfo page shows the following information for the mysql and mysqli modules:

phpinfo mysql and mysqli information

As you can see, installation is very easy.

Summary

Installing MySQL via the 'aptitude' package manager is very simple and ensures you have any security updates if and when they are released.

Installing the necessary packages for MySQL to integrate with Ruby on Rails and PHP is a suitably easy process — allowing you to concentrate on the site design rather than messing with the installation itself.

Ben B

Article Comments:

Sven Clement commented Tue May 19 23:18:36 UTC 2009:

Hey, great tutorial, but you missed out on the need for installing the libmysqlclient-dev meta-package which is needed so that rubygems can build the mysql gem.

Ben commented Wed Jun 17 04:07:23 UTC 2009:

@Sven, that is actually covered in the previous article, http://articles.slicehost.com/2009/4/7/debian-lenny-installing-mysql

Want to comment?


(not made public)

(optional)

(use plain text or Markdown syntax)