How to Install MySQL Database Server on CentOS 5.7

In this post, i will show you on how to install MySQL server on CentOS 5.7. MySQL is a popular choice of database server that can stores and retrieves data for the blog, websites and applications. This post assumed that you have direct internet connection.

Simply run this command to install MySQL server:

root@CentOS57 ~]# yum install mysql mysql-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.vr-zone.com
 * extras: centos.vr-zone.com
 * updates: mirror.yourconnect.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql.i386 0:5.0.77-4.el5_6.6 set to be updated
--> Processing Dependency: perl(DBI) for package: mysql
---> Package mysql-server.i386 0:5.0.77-4.el5_6.6 set to be updated
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server
--> Running transaction check
---> Package perl-DBD-MySQL.i386 0:3.0007-2.el5 set to be updated
---> Package perl-DBI.i386 0:1.52-2.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================
 Package                    Arch             Version                         Repository        Size
====================================================================================================
Installing:
 mysql                      i386             5.0.77-4.el5_6.6                base             4.8 M
 mysql-server               i386             5.0.77-4.el5_6.6                base             9.8 M
Installing for dependencies:
 perl-DBD-MySQL             i386             3.0007-2.el5                    base             148 k
 perl-DBI                   i386             1.52-2.el5                      base             600 k

Transaction Summary
====================================================================================================
Install       4 Package(s)
Upgrade       0 Package(s)

Total download size: 15 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): perl-DBD-MySQL-3.0007-2.el5.i386.rpm                                  | 148 kB     00:01
(2/4): perl-DBI-1.52-2.el5.i386.rpm                                          | 600 kB     00:18
(3/4): mysql-5.0.77-4.el5_6.6.i386.rpm                                       | 4.8 MB     02:19
(4/4): mysql-server-5.0.77-4.el5_6.6.i386.rpm                                | 9.8 MB     03:54
----------------------------------------------------------------------------------------------------
Total                                                                40 kB/s |  15 MB     06:34
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : perl-DBI                                                                     1/4
  Installing     : mysql                                                                        2/4
  Installing     : perl-DBD-MySQL                                                               3/4
  Installing     : mysql-server                                                                 4/4

Installed:
  mysql.i386 0:5.0.77-4.el5_6.6                 mysql-server.i386 0:5.0.77-4.el5_6.6

Dependency Installed:
  perl-DBD-MySQL.i386 0:3.0007-2.el5                   perl-DBI.i386 0:1.52-2.el5

Complete!

Start MySQL server :

[root@CentOS57 ~]# service mysqld start
Initializing MySQL database:  Installing MySQL system tables...
120122 18:37:28 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
120122 18:37:28 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
OK
Filling help tables...
120122 18:37:28 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
120122 18:37:28 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
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 CentOS57 password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

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 mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
                                                           [  OK  ]
Starting MySQL:                                            [  OK  ]

Make MySQL Service auto-start at boot up :

[root@CentOS57 ~]# chkconfig mysqld on