MySQL Server Installation and Initial Configuration on CentOS/RHEL

MySQL is the world's most popular open source relational database management system that runs as a server providing multi-user access to a number of databases.

This guide explains how to install and perform the initial secure configuration of MySQL Server on CentOS/RHEL based systems.

MySQL Server Installation

Install MySQL Server and MySQL Client using 'yum' command.
# yum install mysql-server mysql
Set the MySQL server daemon to start at boot.
# chkconfig mysqld on
Start MySQL.
# service mysqld start

MySQL Server Initial Configuration

Run MySQL secure installation script.
# /usr/bin/mysql_secure_installation
Note: Running all parts of this script is recommended for all MySQL servers in production use! Please read each step carefully!
Perform the next steps :

  • [Y] - Set the root password;
  • [Y] - Remove anonymous users;
  • [Y] - Disallow root login remotely;
  • [Y] - Remove test database and access to it;
  • [Y] - Reload privilege tables.

Once these steps are complete you would be able to log into MySQL Server console with the following command :
# mysql -u root -p