How to Install MySQL Database in Linux Using Yum

MySQL is a widely used, open-source relational database management system. It is an essential component for many applications and websites. This guide will walk you through the process of installing MySQL on a Linux system using the YUM package manager.

This guide is applicable to CentOS, RHEL, and other Linux distributions that use YUM as their package manager.

Step 1: Update YUM Repository

Before installing MySQL, it is a good practice to update the YUM repository to ensure that you are installing the latest available version:

sudo yum update

Step 2: Install MySQL Community Repository

By default, MySQL is not available in the standard YUM repositories. You need to install the MySQL Community Repository to access MySQL packages:

sudo yum install https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

Please note that the URL may change with newer releases. You can find the latest MySQL Community Repository package for your distribution from the official MySQL website.

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

Step 3: Install MySQL Server

Now that the MySQL Community Repository is installed, you can use YUM to install the MySQL server package:

sudo yum install mysql-server

Example:

sudo yum install mysql-server

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * addons: ftp.oss.eznetsols.org
 * base: ftp.oss.eznetsols.org
 * epel: bali.idrepo.or.id
 * extras: ftp.oss.eznetsols.org
 * updates: ftp.oss.eznetsols.org
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-server.x86_64 0:5.0.77-4.el5_5.4 set to be updated
--> Processing Dependency: mysql = 5.0.77-4.el5_5.4 for package: mysql-server
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server
--> Running transaction check
---> Package mysql.x86_64 0:5.0.77-4.el5_5.4 set to be updated
---> Package perl-DBD-MySQL.x86_64 0:3.0007-2.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package              Arch         Version                  Repository     Size
================================================================================
Installing:
 mysql-server         x86_64       5.0.77-4.el5_5.4         updates       9.8 M
Installing for dependencies:
 perl-DBD-MySQL       x86_64       3.0007-2.el5             base          148 k
Updating for dependencies:
 mysql                x86_64       5.0.77-4.el5_5.4         updates       4.8 M

Transaction Summary
================================================================================
Install       2 Package(s)
Upgrade       1 Package(s)

Total download size: 15 M
Is this ok [y/N]: y
Downloading Packages:

(1/3): perl-DBD-MySQL-3.0007-2.el5.x86_64.rpm            | 148 kB     00:17
(2/3): mysql-5.0.77-4.el5_5.4.x86_64.rpm                 | 4.8 MB     06:40
(3/3): mysql-server-5.0.77-4.el5_5.4.x86_64.rpm          | 9.8 MB     15:12
--------------------------------------------------------------------------------
Total                                            11 kB/s |  15 MB     22:20
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating       : mysql                                                    1/4
  Installing     : perl-DBD-MySQL                                           2/4
  Installing     : mysql-server                                             3/4
  Cleanup        : mysql                                                    4/4

Installed:
  mysql-server.x86_64 0:5.0.77-4.el5_5.4

Dependency Installed:
  perl-DBD-MySQL.x86_64 0:3.0007-2.el5

Dependency Updated:
  mysql.x86_64 0:5.0.77-4.el5_5.4

Complete!

Step 4: Start and Enable MySQL Server

After the installation is complete, start the MySQL server and enable it to start automatically on system boot:

sudo systemctl start mysqld
sudo systemctl enable mysqld

Step 5: Secure MySQL Installation

Run the mysql_secure_installation script to perform basic security settings such as setting a root password, removing anonymous users, disabling remote root login, and removing the test database:

sudo mysql_secure_installation

Follow the prompts and answer the questions accordingly to complete the MySQL security setup.

See also  3 Command to Change the Linux Date and Time in CentOS 7/RHEL 7

Programs Mentioned:

  • MySQL – An open-source relational database management system used for managing databases and organizing data.
  • YUM (Yellowdog Updater, Modified) – A package manager used by CentOS, RHEL, and other Linux distributions to install, update, and manage software packages.
  • mysql_secure_installation – A script that performs basic security settings for MySQL, including setting a root password, removing anonymous users, and deleting the test database.

Conclusion

You have successfully installed MySQL on your Linux system using YUM. You can now start using MySQL to manage your databases and organize data for your applications or websites. Remember to follow best practices for database security and maintain regular backups of your data.

See also  How to Install and Configure TigerVNC Server on CentOS 7.1 / RHEL 7.1 / Oracle Linux 7

If you have any questions, comments, or suggestions for improvements, please feel free to share your thoughts. Your feedback helps us provide the most accurate and useful information possible.

Comments

Leave a Reply

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