How to Install MySQL Database Server on CentOS 5.7

In the realm of database servers, MySQL stands as a popular choice among developers and administrators alike. It serves as the backbone for many blogs, websites, and applications, storing and retrieving data as needed.

This guide will walk you through the process of installing MySQL server on CentOS 5.7, a widely-used Linux distribution. This tutorial assumes that you have a direct internet connection. For a deeper understanding of database servers, you can explore our articles on the best web servers.

Installing MySQL Server on CentOS 5.7

To begin the installation process, you need to run the following command:

yum install mysql mysql-server

This command will initiate the installation of MySQL server. It will load plugins, resolve dependencies, and set up the installation process. The system will then check for the necessary packages and dependencies, including ‘mysql’, ‘mysql-server’, ‘perl-DBD-MySQL’, and ‘perl-DBI’.

Once the dependencies are resolved, the system will prompt you to confirm the installation. Enter ‘y’ to proceed. The system will then download the necessary packages and begin the installation process.

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!

Starting MySQL Server

Once the installation is complete, you can start the MySQL server by running the following command:

service mysqld start

This command will initialize the MySQL database and install the MySQL system tables. It will also fill the help tables and provide instructions on how to start the MySQL daemon.

[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  ]

Setting MySQL Root User Password

It’s crucial to set a password for the MySQL root user for security purposes. To do this, start the server and 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 the following command, which will also give you the option of removing the test databases and anonymous user created by default:

/usr/bin/mysql_secure_installation

This step is strongly recommended for production servers.

See also  How to Restart MySQL in Ubuntu

Auto-start MySQL Service at Boot Up

To ensure that the MySQL service starts automatically when the system boots up, run the following command:

chkconfig mysqld on

This command will configure the system to automatically start the MySQL service at boot up.

Commands Mentioned

  • yum install mysql mysql-server – Installs MySQL server
  • service mysqld start – Starts the MySQL server
  • /usr/bin/mysqladmin -u root password ‘new-password’ – Sets the MySQL root user password
  • /usr/bin/mysqladmin -u root -h CentOS57 password ‘new-password’ – Sets the MySQL root user password for a specific host
  • /usr/bin/mysql_secure_installation – Provides a secure way to set the MySQL root user password and remove test databases and anonymous users
  • chkconfig mysqld on – Configures the system to start the MySQL service at boot up
See also  How to Install and Configure Samba SWAT on CentOS 5.5

Conclusion

Installing MySQL server on CentOS 5.7 is a straightforward process that involves running a series of commands to install the server, start the service, set the root user password, and configure the system to start the service at boot up. By following this guide, you can set up a MySQL server on your CentOS 5.7 system and start managing your data effectively. For more insights into different types of servers, you can explore our articles on Apache, Nginx, and LiteSpeed.

If you’re considering different hosting options, you might find our articles on dedicated server, VPS server, cloud hosting, and shared hosting useful.

See also  How to Calculate and List Sizes of MySQL / MariaDB Databases

Remember, the key to effective database management is understanding your tools and using them effectively. Whether you’re a seasoned webmaster or a beginner, this guide provides a solid foundation for installing and managing MySQL server on CentOS 5.7.

FAQs

  1. What is the purpose of installing MySQL server on CentOS 5.7?

    MySQL server is a popular database server that stores and retrieves data for various applications, websites, and blogs. Installing it on CentOS 5.7 allows you to manage your data effectively and efficiently on this Linux distribution.

  2. Why is it important to set a password for the MySQL root user?

    Setting a password for the MySQL root user is crucial for security reasons. It prevents unauthorized access to your databases and protects sensitive data from potential security threats.

  3. What does the command ‘chkconfig mysqld on’ do?

    The command ‘chkconfig mysqld on’ configures the system to automatically start the MySQL service whenever the system boots up. This ensures that the MySQL service is always available when the system is running.

  4. What is the purpose of the ‘/usr/bin/mysql_secure_installation’ command?

    The ‘/usr/bin/mysql_secure_installation’ command provides a secure way to set the MySQL root user password. It also gives you the option to remove test databases and anonymous users created by default, which is strongly recommended for production servers to enhance security.

  5. What are the dependencies required for installing MySQL server on CentOS 5.7?

    The installation of MySQL server on CentOS 5.7 requires several dependencies, including ‘mysql’, ‘mysql-server’, ‘perl-DBD-MySQL’, and ‘perl-DBI’. These dependencies are automatically resolved and installed when you run the ‘yum install mysql mysql-server’ command.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *