Installing MySQL on Ubuntu Hardy is very simple using the 'aptitude' package manager.
This article will go through the install process and also look at what other packages are need for MySQL to integrate with Ruby on Rails and with a standard PHP install.
To begin with, a simple MySQL install:
sudo aptitude install mysql-server mysql-client libmysqlclient15-dev
Note that we have installed the development libs and headers with the 'libmysqlclient15-dev' package - you can leave that out but I have found that they are useful in many siutations.
During the installation of MySQL, you will be presented with the option to install a password:
Setting the MySQL Root password is a recommended step in setting up your Slice. However, it is, of course, up to you.
Should you decide that protecting your production database is a good idea, then simply enter your chosen password as directed.
Unlike previous Ubuntu releases, Hardy asks for a confirmation of the password (which is a good thing!):
Done. It really is as simple as that.
MySQL and Ruby on Rails
I am assuming you have Ruby on Rails installed at this stage (if not, please see the Ubuntu Hardy - Ruby on Rails article).
All we need to do is install one package as follows:
sudo aptitude install libmysql-ruby1.8
Seem suspiciously easy. Let's conduct a quick test to see if all is well:
irb #irb(main):001:0> require 'mysql' #=> true #irb(main):002:0> exit
That seems fine to me.
MySQL and PHP
If you installed Apache and PHP using the Ubuntu Hardy - 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:
As you can see, installation is very easy.
Installing MySQL via the 'aptitude' package manager is very simple and ensure 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.