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)

2
  • 1
    MariaDB is drop-in and you will have no real issues switching. Commented Jan 28, 2018 at 5:21
  • 2
    i would prefer mysql because thats what i have been having in my current production Commented Jan 28, 2018 at 7:26

5 Answers 5

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.

7
  • 4
    Amazon Linux is fairly poor for repository contents and versions. Ubuntu is generally a better option.
    – Tim
    Commented Apr 27, 2018 at 4:46
  • 2
    I do not agree. Commented May 4, 2018 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
    Commented May 4, 2018 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
    Commented Jul 8, 2018 at 20:41
  • 1
    Probably a good move @JeyGeethan The new AL is going to be based of Fedora which is a leading edge distribution, which doesn't sound good for a stable enterprise Linux, but AWS will probably make it more enterprise ready.
    – Tim
    Commented Jan 9, 2022 at 18:06
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
2
  • 2
    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
    Commented Oct 10, 2019 at 23:59
  • Above Q is for 'MySQL' and mariadb will not install things like mysql_config_editor. Commented Dec 3, 2021 at 21:12
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

1
  • This works. Thanks man. Commented Jan 17, 2022 at 19:37
2

You can install it by just 1 command

$ sudo yum install mysql 

Then follow AWS documentation on how to connect rds to mysql

1
  • 4
    on Amazon Linux 2 that seems to resolve to mariadb, not mysql though. Mostly compatible, but not the same thing. Commented Jul 1, 2020 at 10:21
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.
1
  • 1
    That installed MariaDB 5.5, which isn't the 5.6 that was asked for.
    – Daniel P
    Commented Jan 6, 2021 at 10:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .