Ubuntu - MySQL With Rails and PHP Options
Installing MySQL on Ubuntu Intrepid 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 Cloud Server. 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.
After entering the password, Ubuntu Intrepid asks for a confirmation (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 Intrepid - 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 Intrepid - Apache and PHP install 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.
© 2015 Rackspace US, Inc.
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License
See license specifics and DISCLAIMER