Share, , Google Plus, Pinterest,


Posted in:

Install MySQL on CentOS 6

In this post we will explain how to install MySQL on CentOS 6. MySQL is a well known relational database management system. It is open source and was first released in 1995. The source code is available under the GNU General Public License.

MySQL is a central component of LAMP web application software stack and is very popular for use in web applications like Joomla, WordPress, phpBB, TYPO3,… Since July 2013 MySQL is the worlds most widely used open source relational database management system.

Install MySQL
Install MySQL

Let’s start our Install MySQL on CentOS 6 Guide!

1. Install packages

The first step to install MySQL on CentOS is installing mysql-server and php-mysql packages and it’s dependencies:

[root@foo1 ~]# yum install mysql-server php-mysql -y

2. Start on boot

After a successfull package install we must enable MySQL daemon to start at boot time:

[root@foo1 ~]# chkconfig mysqld on
[root@foo1 ~]# chkconfig --list mysqld
mysqld             0:off    1:off    2:on    3:on    4:on    5:on    6:off

3. Edit configuration

Next we need to secure our MySQL instance.

Since we are not accessing our MySQL server from other servers, we will bind MySQL daemon to localhost by editing /etc/my.cnf file and adding an “bind-address=ipaddres” line:

[root@foo1 ~]# cat /etc/my.cnf
# Disabling symbolic-links is recommended to prevent assorted security risks
# Bind to localhost


If you are accessing MySQL from other servers you can enter the IP addresses of the desired servers and separate them with a comma.

4. Start MySQL daemon:

[root@foo1 ~]# /etc/init.d/mysqld start
Initializing MySQL database:  WARNING: The host '' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
Filling help tables...
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h password 'new-password'
Alternatively you can run:
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with
cd /usr/mysql-test ; perl
Please report any problems with the /usr/bin/mysqlbug script!
[  OK  ]
 Starting mysqld:                                           [  OK  ]

5. Set password

Next we can set the password for the MySQL root user:

[root@foo1 ~]# /usr/bin/mysqladmin -u root password 'myHardCorePass'

6. Connect to MySQL

Connect to MySQL instance as root and list existing databases:

[root@foo1 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 4
Server version: 5.1.69 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> show databases;
 | Database           |
 | information_schema |
 | mysql              |
 | test               |
 3 rows in set (0.00 sec)


We have completed our “Install MySQL on CentOS 6” guide. Your MySQL instance is installed and ready to use. Start creating filling them databases … 🙂