Howto Install MySQL on Linux

by RAMESH NATARAJAN on JULY 6, 2008SHARETHIS

Most of the Linux distro comes with MySQL.  If you want use MySQL, my recommendation is that you download the latest version of MySQL and install it yourself. Later you can upgrade it to the latest version when it becomes available. In this article, I will explain how to install the latest free community edition of MySQL on Linux platform.

1. Download the latest stable relase of MySQL

Download mySQL from mysql.com .  Please download the community edition of MySQL for your appropriate Linux platform. I downloaded the “Red Hat Enterprise Linux 5 RPM (x86)”. Make sure to download MySQL Server, Client and “Headers and libraries” from the download page.

MySQL-client-community-5.1.25-0.rhel5.i386.rpm

MySQL-server-community-5.1.25-0.rhel5.i386.rpm

MySQL-devel-community-5.1.25-0.rhel5.i386.rpm

2. Remove the existing default MySQL that came with the Linux distro

Do not perform this on an system where the MySQL database is getting used by some application.

3. Install the downloaded MySQL package

Install the MySQL Server and Client packages as shown below.

This will also display the following output and start the MySQL daemon automatically.

Install the “Header and Libraries” that are part of the MySQL-devel packages.

Note: When I was compiling PHP with MySQL option from source on the Linux system, it failed with the following error. Installing the MySQL-devel-community package fixed this problem in installing PHP from source.

4.  Perform post-install security activities on MySQL.

At a bare minimum you should set a password for the root user as shown below:

The best option is to run the mysql_secure_installation script that will take care of all the typical security related items on the MySQL as shown below. On a high level this does the following items:

Change the root password

Remove the anonymous user

Disallow root login from remote machines

Remove the default sample test database

5.  Verify the MySQL installation:

You can check the MySQL installed version by performing mysql -V as shown below:

Connect to the MySQL database using the root user and make sure the connection is successfull.

Follows the steps below to stop and start MySQL

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐