31

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)

Tim
  • 33,870
  • 7
  • 56
  • 84

6 Answers6

33

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.

pizza247
  • 103
  • 3
12

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

sudo yum -y install mariadb-server
sudo service mariadb start
Jonathan
  • 1,359
8

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

Michael Hampton
  • 252,907
2

You can install it by just 1 command

$ sudo yum install mysql 

Then follow AWS documentation on how to connect rds to mysql

cubick
  • 141
0

For people who need mysqldump (ie, for Wordpress on ec2), install mariadb from the native amzn2-core repo.

   yum install mariadb.x86_64
   mysqldump -v

Info about the package:

# yum info mariadb.x86_64
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Installed Packages
Name        : mariadb
Arch        : x86_64
Epoch       : 1
Version     : 5.5.68
Release     : 1.amzn2
Size        : 49 M
Repo        : installed
From repo   : amzn2-core
Summary     : A community developed branch of MySQL
URL         : http://mariadb.org
License     : GPLv2 with exceptions and LGPLv2 and BSD
Description : MariaDB is a community developed branch of MySQL.
        : MariaDB is a multi-user, multi-threaded SQL database server.
        : It is a client/server implementation consisting of a server daemon           (mysqld)
        : and many different client programs and libraries. The base package
        : contains the standard MariaDB/MySQL client programs and generic MySQL files.
semtex41
  • 159
0

If you facing this issue:"Public key for mysql-community-libs-5.7.44-1.el7.x86_64.rpm is not installed. Failing package is: mysql-community-libs-5.7.44-1.el7.x86_64 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql"

Try out these commands:

Download and install the MySQL repository RPM sudo wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm sudo yum localinstall mysql57-community-release-el7-11.noarch.rpm

Install MySQL community server sudo yum install mysql-community-server

Start MySQL service sudo systemctl start mysqld.service

If the issue persists, import the GPG key manually sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql

As a last resort, disable GPG check temporarily sudo yum --nogpgcheck install mysql-community-server

Dave M
  • 4,494