Cyberithub

How to Install MySQL 5.5 Server on CentOS 7 with Easy Steps

Advertisements

In this article, we will go through one of the multiple ways to install MySQL 5.5 Server on CentOS 7 through YUM utility. There are ways to install MySQL 5.5 which we will see in later articles.

Here we will keep our focus on all the important steps required to install MySQL 5.5 through yum command in the most widely used versions of RHEL/CentOS and Fedora distributions.

MySQL is a well known open-source database management System used mostly along with LAMP (Linux, Apache, MySQL and PHP) Stack. It uses RDBMS(Relational Database Management System) to manage its data.

How to Install MySQL 5.5 Server on CentOS 7 with Easy Steps 2

Steps to Install MySQL 5.5 Server on CentOS 7

Also Read: 6 Easy Steps to Install Sendmail Command in Linux (RHEL/CentOS 7/8)

Step 1: Prerequisites

a)You need to have running RHEL/CentOS 7/8 based Systems.

b)You should have yum tool installed in your System. Please Check Top 22 YUM Command Examples in RedHat/CentOS 7 to know more about yum utility.

c)You should have root or sudo access to run Privileged Commands. Please Check How to Add User to Sudoers to know more about providing sudo access to the User.

Step 2: Update Your System Using yum update command

If you are going to or planning to install a new package in your System then the first thing you need to do is to update your System using yum update -y command as shown below. This will update all the installed packages with the latest version so that all the dependent packages will remain fully updated.

[root@localhost ~]# yum update -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.piconets.webwerks.in
* extras: mirrors.piconets.webwerks.in
* updates: mirrors.piconets.webwerks.in
base | 3.6 kB 00:00
extras | 2.9 kB 00:00
updates | 2.9 kB 00:00
updates/7/x86_64/primary_db | 1.9 MB 00:00
Resolving Dependencies
--> Running transaction check
---> Package kernel.x86_64 0:3.10.0-1062.1.2.el7 will be installed
---> Package kernel-tools.x86_64 0:3.10.0-1062.1.1.el7 will be updated
---> Package kernel-tools.x86_64 0:3.10.0-1062.1.2.el7 will be an update
---> Package kernel-tools-libs.x86_64 0:3.10.0-1062.1.1.el7 will be updated
---> Package kernel-tools-libs.x86_64 0:3.10.0-1062.1.2.el7 will be an update
---> Package python-perf.x86_64 0:3.10.0-1062.1.1.el7 will be updated
---> Package python-perf.x86_64 0:3.10.0-1062.1.2.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
kernel x86_64 3.10.0-1062.1.2.el7 updates 50 M
Updating:
kernel-tools x86_64 3.10.0-1062.1.2.el7 updates 7.8 M
kernel-tools-libs x86_64 3.10.0-1062.1.2.el7 updates 7.7 M
python-perf x86_64 3.10.0-1062.1.2.el7 updates 7.8 M

Transaction Summary
================================================================================
Install 1 Package
Upgrade 3 Packages

Total download size: 73 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/4): kernel-tools-3.10.0-1062.1.2.el7.x86_64.rpm | 7.8 MB 00:00:04
(2/4): kernel-tools-libs-3.10.0-1062.1.2.el7.x86_64.rpm | 7.7 MB 00:00:04
(3/4): python-perf-3.10.0-1062.1.2.el7.x86_64.rpm | 7.8 MB 00:00:07
(4/4): kernel-3.10.0-1062.1.2.el7.x86_64.rpm | 50 MB 00:00:12
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 5.8 MB/s | 73 MB 00:00:12
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : kernel-tools-libs-3.10.0-1062.1.2.el7.x86_64 1/7
Updating : kernel-tools-3.10.0-1062.1.2.el7.x86_64 2/7
Updating : python-perf-3.10.0-1062.1.2.el7.x86_64 3/7
Installing : kernel-3.10.0-1062.1.2.el7.x86_64 4/7
Cleanup : kernel-tools-3.10.0-1062.1.1.el7.x86_64 5/7
Cleanup : kernel-tools-libs-3.10.0-1062.1.1.el7.x86_64 6/7
Cleanup : python-perf-3.10.0-1062.1.1.el7.x86_64 7/7
Verifying : kernel-tools-3.10.0-1062.1.2.el7.x86_64 1/7
Verifying : kernel-3.10.0-1062.1.2.el7.x86_64 2/7
Verifying : python-perf-3.10.0-1062.1.2.el7.x86_64 3/7
Verifying : kernel-tools-libs-3.10.0-1062.1.2.el7.x86_64 4/7
Verifying : kernel-tools-libs-3.10.0-1062.1.1.el7.x86_64 5/7
Verifying : kernel-tools-3.10.0-1062.1.1.el7.x86_64 6/7
Verifying : python-perf-3.10.0-1062.1.1.el7.x86_64 7/7

Installed:
kernel.x86_64 0:3.10.0-1062.1.2.el7

Updated:
kernel-tools.x86_64 0:3.10.0-1062.1.2.el7 kernel-tools-libs.x86_64 0:3.10.0-1062.1.2.el7 python-perf.x86_64 0:3.10.0-1062.1.2.el7

Complete!

 

Step 3: Install and Enable MySQL Repository

After successfully updating your system you can now install and enable the MySQL 5.5 Community version repository using below yum install command.

[root@localhost ~]# yum install http://repo.mysql.com/yum/mysql-5.5-community/el/7/x86_64/mysql-community-release-el7-5.noarch.rpm
Loaded plugins: fastestmirror
mysql-community-release-el7-5.noarch.rpm | 6.0 kB 00:00:00
Examining /var/tmp/yum-root-8v6BM_/mysql-community-release-el7-5.noarch.rpm: mysql-community-release-el7-5.noarch
Marking /var/tmp/yum-root-8v6BM_/mysql-community-release-el7-5.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-release.noarch 0:el7-5 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================================
Installing:
mysql-community-release noarch el7-5 /mysql-community-release-el7-5.noarch 4.3 k

Transaction Summary
========================================================================================================================================================================
Install 1 Package

Total size: 4.3 k
Installed size: 4.3 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mysql-community-release-el7-5.noarch 1/1
Verifying : mysql-community-release-el7-5.noarch 1/1

Installed:
mysql-community-release.noarch 0:el7-5

Complete!

 

Step 4: Install MySQL Server

Once repo is enabled then you can run yum install -y mysql-community-server to install MySQL Server as shown below.

[root@localhost ~]# yum install -y mysql-community-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                                                                                                             | 8.7 kB  00:00:00
 * base: mirrors.piconets.webwerks.in
 * epel: download.nus.edu.sg
 * extras: mirrors.piconets.webwerks.in
 * updates: mirrors.piconets.webwerks.in
base                                                                                                                                             | 3.6 kB  00:00:00
epel                                                                                                                                             | 4.7 kB  00:00:00
extras                                                                                                                                           | 2.9 kB  00:00:00
mysql-connectors-community                                                                                                                       | 2.5 kB  00:00:00
mysql-tools-community                                                                                                                            | 2.5 kB  00:00:00
mysql56-community                                                                                                                                | 2.5 kB  00:00:00
updates                                                                                                                                          | 2.9 kB  00:00:00
(1/5): install mysql56-community/x86_64/primary_db                                                                                                       | 265 kB  00:00:00
(2/5): install mysql-connectors-community/x86_64/primary_db                                                                                              |  62 kB  00:00:00
(3/5): install mysql-tools-community/x86_64/primary_db                                                                                                   |  76 kB  00:00:00
(4/5): epel/x86_64/primary_db                                                                                                                    | 6.9 MB  00:00:03
(5/5): epel/x86_64/updateinfo                                                                                                                    | 1.0 MB  00:00:06
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.6.49-2.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.6.49-2.el7 for package: install mysql-community-server-5.6.49-2.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.6.10 for package: install mysql-community-server-5.6.49-2.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.6.49-2.el7 will be obsoleting
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.6.10 for package: install mysql-community-client-5.6.49-2.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.6.49-2.el7 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.6.49-2.el7 will be obsoleting
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
 Package                                         Arch                            Version                               Repository                                  Size
========================================================================================================================================================================
Installing:
 mysql-community-client                          x86_64                          5.6.49-2.el7                          mysql56-community                           21 M
     replacing  mariadb.x86_64 1:5.5.65-1.el7
 mysql-community-libs                            x86_64                          5.6.49-2.el7                          mysql56-community                          2.2 M
     replacing  mariadb-libs.x86_64 1:5.5.65-1.el7
 mysql-community-server                          x86_64                          5.6.49-2.el7                          mysql56-community                           67 M
Installing for dependencies:
 mysql-community-common                          x86_64                          5.6.49-2.el7                          mysql56-community                          289 k

Transaction Summary
========================================================================================================================================================================
Install  3 Packages (+1 Dependent package)

Total download size: 90 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql56-community/packages/mysql-community-common-5.6.49-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Public key for mysql-community-common-5.6.49-2.el7.x86_64.rpm is not installed
(1/4): mysql-community-common-5.6.49-2.el7.x86_64.rpm                                                                                            | 289 kB  00:00:00
(2/4): mysql-community-libs-5.6.49-2.el7.x86_64.rpm                                                                                              | 2.2 MB  00:00:00
(3/4): mysql-community-client-5.6.49-2.el7.x86_64.rpm                                                                                            |  21 MB  00:00:04
(4/4): mysql-community-server-5.6.49-2.el7.x86_64.rpm                                                                                            |  67 MB  00:00:10
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                   7.6 MB/s |  90 MB  00:00:11
Retrieving key from file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
 Userid     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
 Package    : mysql-community-release-el7-5.noarch (@/mysql-community-release-el7-5.noarch)
 From       : file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : install mysql-community-common-5.6.49-2.el7.x86_64                                                                                                           1/4
  Installing : install mysql-community-libs-5.6.49-2.el7.x86_64                                                                                                             2/4
  Installing : install mysql-community-client-5.6.49-2.el7.x86_64                                                                                                           3/4
  Installing : install mysql-community-server-5.6.49-2.el7.x86_64                                                                                                           4/4
  Verifying  : mysql-community-client-5.6.49-2.el7.x86_64                                                                                                           1/4
  Verifying  : mysql-community-common-5.6.49-2.el7.x86_64                                                                                                           2/4
  Verifying  : mysql-community-server-5.6.49-2.el7.x86_64                                                                                                           3/4
  Verifying  : mysql-community-libs-5.6.49-2.el7.x86_64                                                                                                             4/4                                                                                                                 6/6

Installed:
  mysql-community-client.x86_64 0:5.6.49-2.el7            mysql-community-libs.x86_64 0:5.6.49-2.el7            mysql-community-server.x86_64 0:5.6.49-2.el7

Dependency Installed:
  mysql-community-common.x86_64 0:5.6.49-2.el7

Complete!

 

Step 5: Check if it is installed properly using rpm tool

After successful installation of all the MySQL Packages you can verify the installation by querying the package details from RPM DB using rpm -qa | grep -i mysql-community command as shown below. It will show all the mysql-community packages installed in the RPM Database.

[root@localhost ~]# rpm -qa | grep -i mysql-community
mysql-community-common-5.6.49-2.el7.x86_64
mysql-community-server-5.6.49-2.el7.x86_64
mysql-community-release-el7-5.noarch
mysql-community-client-5.6.49-2.el7.x86_64
mysql-community-libs-5.6.49-2.el7.x86_64

 

Step 6: Start MySQL Service 

Now we need to start the MySQL Server using service mysqld start command as shown below. You can also use systemctl start mysqld command to start the mysqld service. Both of the commands will work fine.

[root@localhost ~]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service

Now if you check the mysqld service status using service mysqld status or by using systemctl status mysqld command then you can see it is in running state. If there will be any error while starting the service then it will visible area.

[root@localhost ~]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2020-08-14 14:44:59 EDT; 18s ago
  Process: 1881 ExecStartPost=/usr/bin/mysql-systemd-start post (code=exited, status=0/SUCCESS)
  Process: 1868 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 1880 (mysqld_safe)
    Tasks: 23
   CGroup: /system.slice/mysqld.service
           ├─1880 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─2046 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --pid-file=/var/run/m...

Aug 14 14:44:58 localhost systemd[1]: Starting MySQL Community Server...
Aug 14 14:44:58 localhost mysqld_safe[1880]: 200814 14:44:58 mysqld_safe Logging to '/var/log/mysqld.log'.
Aug 14 14:44:58 localhost mysqld_safe[1880]: 200814 14:44:58 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Aug 14 14:44:59 localhost systemd[1]: Started MySQL Community Server.

 

Step 7: Setting Up MySQL Server Using mysql_secure_installation

This is a very important step where you need to configure the Server credentials using mysql_secure_installation utility before login to the Database and set the other important options as well to secure the database.

[root@localhost ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] n
... skipping.

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] n
... skipping.

Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
... skipping.

By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] n
... skipping.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
... Success!


All done! If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

After performing above step you need to again restart the server either using systemctl restart mysqld or service mysqld restart command as shown below.

[root@localhost ~]# systemctl restart mysqld

 

Step 8: Login to MySQL

After setting the root user credentials you can try to login to the MySQL Server using mysql -u root -p command as shown below. You can use -u option to specify the User Name and -p option to specify the User Password. This is the same password which you have set in Step 6. You can check more about mysql option on Man Page.

[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.49 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, 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
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

 

 

Popular Recommendations:-

How to Create Table in MySQL 5.5 with Easy Steps

How to Disable IPV6 on Linux (CentOS / RHEL 7/8) Using 4 Best Steps

How to Set MariaDB root Password in RHEL/CentOS 7/8 Using Simple mysql_secure_installation

Introduction to SQL Injection Attacks in MySQL (v5.5)

How to Limit CPU Limit of a Process Using CPULimit in Linux (RHEL/CentOS 7/8)

How to Install Rust Programming Language in Linux Using 6 Best Steps

Openssl Tutorial: Generate and Install Certificate on Apache Server in 8 Easy Steps

How to Enable or Disable SELinux Temporarily or Permanently on RedHat/CentOS 7/8

Top 12 Nmap Commands to Scan Remote Host with Best Practices

1 thought on “How to Install MySQL 5.5 Server on CentOS 7 with Easy Steps”

  1. If you're trying to install MySQL 5.x on CentOS 8, you need to run `yum module disable mysql` to disable yum's MySQL module. This module will prevent other MySQL versions from being installed via yum.

    Reply

Leave a Comment