28

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
  • 30,383
  • 6
  • 47
  • 77
Jey Geethan
  • 735
  • 1
  • 6
  • 11

5 Answers5

30

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.

Jey Geethan
  • 735
  • 1
  • 6
  • 11
  • 4
    Amazon Linux is fairly poor for repository contents and versions. Ubuntu is generally a better option. – Tim Apr 27 '18 at 04:46
  • 2
    I do not agree. – Jey Geethan May 04 '18 at 02: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 04 '18 at 05: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 08 '18 at 20:41
  • After 3 years, I have to say that I moved away from Amazon AMIs. @Tim – Jey Geethan Jan 09 '22 at 12:02
  • 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 Jan 09 '22 at 18:06
10

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,279
  • 2
  • 20
  • 28
  • 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 Oct 10 '19 at 23:59
  • Above Q is for 'MySQL' and mariadb will not install things like mysql_config_editor. – Rich Andrews Dec 03 '21 at 21:12
3

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
  • 237,123
  • 42
  • 477
  • 940
2

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

Then follow AWS documentation on how to connect rds to mysql

Rohit Jere
  • 29
  • 1
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
  • 149
  • 3