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

58,621

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

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

Solution 4

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

Then follow AWS documentation on how to connect rds to mysql

Share:
58,621

Related videos on Youtube

Jey Geethan
Author by

Jey Geethan

Updated on September 18, 2022

Comments

  • Jey Geethan
    Jey Geethan over 1 year

    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)

    • Michael Hampton
      Michael Hampton over 6 years
      MariaDB is drop-in and you will have no real issues switching.
    • Jey Geethan
      Jey Geethan over 6 years
      i would prefer mysql because thats what i have been having in my current production
  • Tim
    Tim about 6 years
    Amazon Linux is fairly poor for repository contents and versions. Ubuntu is generally a better option.
  • Jey Geethan
    Jey Geethan about 6 years
    I do not agree.
  • Tim
    Tim about 6 years
    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.
  • Ted Cahall
    Ted Cahall almost 6 years
    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.
  • guessimtoolate
    guessimtoolate almost 4 years
    on Amazon Linux 2 that seems to resolve to mariadb, not mysql though. Mostly compatible, but not the same thing.
  • Daniel P
    Daniel P over 3 years
    That installed MariaDB 5.5, which isn't the 5.6 that was asked for.
  • Rich Andrews
    Rich Andrews over 2 years
    Above Q is for 'MySQL' and mariadb will not install things like mysql_config_editor.
  • Jey Geethan
    Jey Geethan over 2 years
    After 3 years, I have to say that I moved away from Amazon AMIs. @Tim
  • Tim
    Tim over 2 years
    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.
  • Omar Dulaimi
    Omar Dulaimi over 2 years
    This works. Thanks man.