Friday 17 September 2010

Starting off with MySQL

Ive just had to install a MySQL server on one of our Debian machine and thought it would be great to add a short tutorial for people who would like to start installing and configuring their MySQL databases under linux. I'll assume that you are using a Debian based linux, but I cant imagine the commands being too different in any other linux.

So what is MySQL? It is a Relational Database Management System (RDMS), which runs on a server/client architecture and provides multi-user access to the data simultaneously. Did I also mention that its insanely fast, and a great place to learn about RDMS without having to pay $$$ for an enterprise database. (Quite recently they were acquired by oracle, but the development of the community edition is still ongoing).

MySQL is "the worlds most popular open source database" in their own words, and I have a feeling they are right about that, as it appears everyone who develops web application usually follows the PHP/MySQL or RoR/MySQL path to start off with.

Ok, heard enough? Lets get on with it already.


Installation:

Fire up a terminal window and give yourself superuser access, using the 'su' command. Ubuntu users, remember to 'sudo' your commands.

apt-get install mysql-server

That pulls up the latest version of the mysql server from the debian repository and installs it. Read the instructions while installation is ongoing, and if you are in a server environment you will need to allow the mysql database to start at boot up.


Usage:

To test your installation type:
mysql

If that lets you in to the database console, voila mysql has been successfully installed, although you dont really need to do this, as the installation should quit cleanly without errors. If it complains, ensure you have hall the needed packages and google your way out of the mess.

now 'quit' out of the mysql console, and set your root password as follows:

mysqladmin -u root password NEWPASSWORD

If you want more information on using the database, the MySQL site has some great webinars. Go check them out: http://www.mysql.com/news-and-events/on-demand-webinars/

Thats all I have for you for now, I dont really have time or space to describe mysql usage here, so we can leave that as a topic for a later date.