Installing MySQL in EC2 Jump Server

As a best practice, bastion hosts (jump servers) are frequently used to access privately accessible hosts inside of a system environment. 

A system on a network used to access and maintain an application or database system that is not intended to be publicly accessible, in a different security zone, is known as a jump server, jump host, or jump box. A hardened and monitored device that spans two different security zones and offers a regulated means of access between them is called a jump server.

Mysql client/server must be installed in order to use the AWS RDS and to conduct backup and restoration operations through a jump server. If you want to run mysqldump command in the ec2 that connects to AWS RDS MySQL database, you can install mariadb or mysql as shown below.

To search the available installers.
[ec99-root@ip-99-9-9-991 ~]$ yum search mysql

If you are getting a permission error then use ‘sudo’
[ec99-root@ip-99-9-9-991 ~]$ sudo yum search mysql

Failed to set locale, defaulting to C
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
===============================================================================N/S matched: mysql ===============================================================================
MySQL-python.x86_64 : An interface to MySQL
apr-util-mysql.x86_64 : APR utility library MySQL DBD driver

dovecot-mysql.x86_64 : MySQL back end for dovecot
freeradius-mysql.x86_64 : MySQL support for freeradius
libdbi-dbd-mysql.x86_64 : MySQL plugin for libdbi
mysql-connector-java.noarch : Official JDBC driver for MySQL
mysql-connector-odbc.x86_64 : ODBC driver for MySQL
pcp-pmda-mysql.x86_64 : Performance Co-Pilot (PCP) metrics for MySQL
perl-DBD-MySQL.x86_64 : A MySQL interface for Perl
php-mysql.x86_64 : A module for PHP applications that use MySQL databases
php-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases
qt-mysql.x86_64 : MySQL driver for Qt’s SQL classes
qt-mysql.i686 : MySQL driver for Qt’s SQL classes
qt3-MySQL.x86_64 : MySQL drivers for Qt 3’s SQL classes
qt3-MySQL.i686 : MySQL drivers for Qt 3’s SQL classes
qt5-qtbase-mysql.x86_64 : MySQL driver for Qt5’s SQL classes
qt5-qtbase-mysql.i686 : MySQL driver for Qt5’s SQL classes
redland-mysql.x86_64 : MySQL storage support for Redland
rsyslog-mysql.x86_64 : MySQL support for rsyslog
mariadb.x86_64 : A community developed branch of MySQL
mariadb-devel.x86_64 : Files for development of MariaDB/MySQL applications
mariadb-libs.x86_64 : The shared libraries required for MariaDB/MySQL clients
mariadb-libs.i686 : The shared libraries required for MariaDB/MySQL clients

You can select mariadb which will install mysqldump and mysql executable files that help in backup and restore the databases
[ec99-root@ip-99-9-9-991 ~]$ sudo yum install mariadb.x86_64

Or you can simply execute the following command to install mysql. Both will anyways download the mariadb which is a compatible drop-in replacement for the widely used MySQL database technology.

[ec99-root@ip-99-9-9-991 ~]$ sudo yum install mysql

Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
amzn2-core | 3.7 kB 00:00:00

Resolving Dependencies
–> Running transaction check
—> Package mariadb.x86_64 1:5.5.68-1.amzn2 will be installed
–> Finished Dependency Resolution

Dependencies Resolved
===============================================================================Package Arch Version Repository Size
===============================================================================Installing:
mariadb x86_64 1:5.5.68-1.amzn2 amzn2-core 8.8 M

Transaction Summary
===============================================================================Install 1 Package
Total download size: 8.8 M
Installed size: 49 M
Is this ok [y/d/N]: y

Downloading packages:
mariadb-5.5.68-1.amzn2.x86_64.rpm | 8.8 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 1:mariadb-5.5.68-1.amzn2.x86_64 1/1
Verifying : 1:mariadb-5.5.68-1.amzn2.x86_64 1/1

Installed:
mariadb.x86_64 1:5.5.68-1.amzn2

Complete!

[ec99-root@ip-99-9-9-991 ~]$ mysql –version
mysql Ver 15.1 Distrib 5.5.68-MariaDB, for Linux (x86_64) using readline 5.1

You can check which version of MySQL/MariaDB is installed using the below command. 
[ec99-root@ip-99-9-9-991 ~]$ rpm -qf /usr/bin/mysqldump
mariadb-5.5.68-1.amzn2.x86_64

If you want to uninstall the above-specified installation, then use the below command.
[ec99-root@ip-99-9-9-991 ~]$ sudo yum erase mysql
Removed:
mariadb.x86_64 1:5.5.68-1.amzn2
Complete!

Now you can run your mysqldump command to backup the database.


INSTALLING MYSQL Community Server:

If you want to install mysql community server, follow the below steps.

# First check if you have installed any mysql packages
[ec99-root@ip-99-9-9-991 ~]$ sudo yum list installed | grep mysql

# Remove the packages if any.
sudo yum remove PackageName
Example:
[ec99-root@ip-99-9-9-991 ~]$ sudo yum remove mysql80-community-release.noarch

# Cleanup process.
[ec99-root@ip-99-9-9-991 ~]$ sudo yum clean all –verbose
Loading “extras_suggestions” plugin
Loading “langpacks” plugin
Loading “priorities” plugin
Loading “update-motd” plugin
Adding en to language list
Config time: 0.338
Yum version: 3.4.3
Cleaning repos: amzn2-core amzn2extra-docker amzn2extra-kernel-5.10
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos

# Update
[ec99-root@ip-99-9-9-991 ~]$ sudo yum update

Setting-up the Yum Repository. Use “Sudo” if you are getting permission errors.
[ec99-root@ip-99-9-9-991 ~]$ rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm

Disabling all repositories in MySQL repo file. Use “Sudo” if you are getting permission errors and ensure the quotes are correctly copied.
[ec99-root@ip-99-9-9-991 ~]$ sed -i ‘s/enabled=1/enabled=0/’ /etc/yum.repos.d/mysql-community.repo

Before proceeding to final step of installing MySQL, import the GPG key first. Use “Sudo” if you are getting permission errors
[ec99-root@ip-99-9-9-991 ~]$  rpm –import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

The final step – Installing MySQL Community Server. Use “Sudo” if you are getting permission errors
[ec99-root@ip-99-9-9-991 ~]$ yum –enablerepo=mysql80-community install mysql-community-server

Now you have MySQL community server installed on your machine through which you can run the backup and restore commands to your RDS Instances.

Happy learning..!!!

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s