How to Install MySQL 8 on Amazon Linux 2 EC2.

We will learn about “How to Install MySQL 8 on Amazon Linux 2 EC2”, we will look at the installation for MySQL 8 step by step in Amazon Linux 2 EC2 .

MySQL is the Relation Database, which is used to store the data. It Is open-source and widely used in the industries.

MySQL written in C and C++. It has also been tested to be a “fast, stable and true multi-user, multi-threaded SQL database server”.


First, we will download the MySQL 8 Community Edition installer for Amazon Linux 2 EC2.

We will learn about "How to install MySQL 8 on CentOS 8 Linux", we will look at the installation for MySQL 8 step by step in CentOS 8.

Now right-click on “Download” and then select “Copy link address” and move to a terminal to download the bundle of MySQL 8.

So, now we will install wget in Amazon Linux EC2 to download the MySQL Packages.

# yum install wget

The QUICK view to installing MySQL in Linux read the POST to get detailed knowledge about the installation.

Quick view to Install MySQL 8 on Amazon Linux 2 EC2

1: Download the Package of MySQL Community Edition in Amazon Linux 2 EC2

# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.25-1.el8.x86_64.rpm-bundle.tar

2: Extract the Package of MySQL 8 onAmazon Linux 2 EC2.

# tar -xvf mysql-8.0.25-1.el8.x86_64.rpm-bundle.tar

3: Install the Package of MySQL 8 using yum and rpm command on Amazon Linux 2 EC2.

# yum install perl-Data-Dumper perl-JSON openssl-devel -y
# rpm -vih *.rpm

4: Start the service of MySQL 8 on Amazon Linux 2 EC2.

# systemctl start mysqld
# systemctl enable mysqld

5: Configure MySQL with “mysql_secure_installation”.

# mysql_secure_installation

6: Logged in and Check the Database of MySQL in Amazon Linux 2 EC2.

# mysql -h localhost -u[username] -p[password]


Install MySQL 8 on Amazon Linux 2 EC2 Step by Step

STEP 1: Download the Package of MySQL Community Edition in Amazon Linux 2 EC2.

# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.25-1.el8.x86_64.rpm-bundle.tar

So, once the file has been downloaded as “mysql-8.0.25.X.X.rpm-bundle.tar” next, we have to extract the file using tar command.

STEP 2: Extract the Package of MySQL 8 on Amazon Linux 2 EC2.

# tar -xvf  mysql-8.0.25-1.el8.x86_64.rpm-bundle.tar

So, after extraction now lets install the packages using the rpm command.

STEP 3:Install the Package of MySQL 8 using rpm and yum command on Amazon Linux 2 EC2.

So, before installing we got some dependencies error.

We will learn about "How to install MySQL 8 on CentOS 8 Linux", we will look at the installation for MySQL 8 step by step in CentOS 8.
Dependencies error

Let’s install the dependencies intoAmazon Linux 2 EC2

# yum install perl-Data-Dumper perl-JSON openssl-devel -y

And then use rpm command to install the MySQL 8 Package in Amazon Linux 2 EC2.

We will learn about "How to install MySQL 8 on CentOS 8 Linux", we will look at the installation for MySQL 8 step by step in CentOS 8.
rpm command install
# rpm -vih *.rpm

STEP 4: Start the service of MySQL in Amazon Linux 2 EC2.

# systemctl start mysqld

Start the service using systemctl command and if we want to start the service at the time of booting use below command.

# systemctl enable mysqld
STEP 5: Configure MySQL in Amazon Linux 2 EC2.
We will learn about "How to install MySQL 8 on CentOS 8 Linux", we will look at the installation for MySQL 8 step by step in CentOS 8.
Starting the MySQL

So, after that check, the “mysqld.log” in /var/log/ folder, were you will get the temporary password.

# cat /var/log/mysqld.log
We will learn about "How to install MySQL 8 on CentOS 8 Linux", we will look at the installation for MySQL 8 step by step in CentOS 8.
Password that to be used in mysql_secure_installation

We can see the logs very clearly the logs, let’s set our own password using “mysql_secure_installation”

[[email protected] ~]# mysql_secure_installation
We will learn about "How to install MySQL 8 on CentOS 8 Linux", we will look at the installation for MySQL 8 step by step in CentOS 8.
mysql_secure_installation

So, you can “Enter a password of your choice” but there is some policy in MySQL for the password.

  1. The password length should be 8 or more than that.
  2. There should be one special character like “@#$!”
  3. There should be one UPPER case letter.
  4. Finally, there should be one LOWER case letter.
mysql_secure_installation

So then it will ask to remove the anonymous user press “y” to remove.

Next, it will prompt to Disallow root login remotely? means if we want to login from the root user remotely, press y|Y or press any other key to No.

mysql_secure_installation

So after that, it will ask to remove the test database and reload the changes and that’s Done.

STEP 6: Check the version of installed MySQL 8 on Amazon Linux 2 EC2.

So we can check the version with two ways, by using the –version parameter with “mysql” command.

# mysql –version

Also, we can check the version by take login to the MySQL 8 server.

# mysql -h localhost -uUsername -pPassword

Let’s check the database after login, use “>show databases”

show databases
mysql> show databases;

If you want to Install MySQL 8 on Ubuntu 20.04 then follow the link. If you want to check the POST to Install MySQL in Linux. Want to Install MySQL on Ubuntu 18.04. Install MySQL 8 in Rocky Linux.


Give your valuable time