amazon linux 2 ami - aws - How to install mysql in Amazon Linux 2?

I am trying to install mysql in amazon linux 2 ami and am not able to do it.

sudo yum install mysql56-server -> doesn't work
amazon-linux-extras list -> doesn't list mysql

I do not want mariadb since I have more exposure to mysql (even if both are the same)


Solution 1:

I got the answer myself. Follow the below steps:

sudo wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
sudo yum localinstall mysql57-community-release-el7-11.noarch.rpm 
sudo yum install mysql-community-server
systemctl start mysqld.service

The key is to add the source repo and then install since Amazon Linux 2 doesn't have the default repos in place already.

Solution 2:

Amazon's documentation seems to recommend using MariaDB (a fork of MySQL). To install:

sudo yum -y install mariadb-server
sudo service mariadb start

Solution 3:

You can install it by just 1 command sudo yum install mysql

Then follow AWS documentation on how to connect rds to mysql

Solution 4:

I have installed MySQL on Amazon Linux 2

here are the commands

Install MySQL server in Amazon Linux 2

sudo yum update -y 

sudo yum install -y mariadb-server

sudo systemctl enable mariadb

sudo systemctl start mariadb

sudo mysql_secure_installation

I have created a video on this here

https://www.youtube.com/watch?v=h6sdw6wWNbY