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)

  • 1
    MariaDB is drop-in and you will have no real issues switching. – Michael Hampton Jan 28 '18 at 5:21
  • i would prefer mysql because thats what i have been having in my current production – Jey Geethan Jan 28 '18 at 7:26

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.

| improve this answer | |
  • 3
    Amazon Linux is fairly poor for repository contents and versions. Ubuntu is generally a better option. – Tim Apr 27 '18 at 4:46
  • 1
    I do not agree. – Jey Geethan May 4 '18 at 2:14
  • Can you elaborate Jey ? I know for example that I needed to build Nginx to get a recent version, I had to use an old version of fail2ban, HHVM was difficult (I gave up and used PHP), and in general some of the packages I've tried to use are out of date. Maybe things have improved in the past year or so since I looked, but just about every piece of software supports Ubuntu. – Tim May 4 '18 at 5:35
  • Totally agree Tim. The old AMI was even better than AMI 2. On AMI 2, I had to work to add the Zabbix agent by pretending the machine was RHEL6. Now having trouble just getting a simple mysql-client live without installing the entire MariaDB server with it. Ubuntu 16.04 has better native package support than AMI LInux 2. I am wasting too much time with this version. Back to Ubuntu since Amazon is pushing AMI 2 over old AMI. However, the answer above also works to grab the mysql client so I gave it an upvote for those that want to stick to AMI 2 and just want the client. – Ted Cahall Jul 8 '18 at 20:41

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

sudo yum -y install mariadb-server
sudo service mariadb start
| improve this answer | |
  • 1
    Updating modules: Sorry, but we support MySQL version 5.6.0 or later. ... Some software packages are far more fickle that Amazon. Also, updating the syntax for table definitions in xGB sql files is a bit of a hassle. – ppostma1 Oct 10 '19 at 23:59

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

Then follow AWS documentation on how to connect rds to mysql

| improve this answer | |
  • on Amazon Linux 2 that seems to resolve to mariadb, not mysql though. Mostly compatible, but not the same thing. – guessimtoolate Jul 1 at 10:21

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


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.