AWS EC2 MySQL Client Installation

Viewed 946

I am installing MySQL client in my EC2 instance via Cloudformation using the below command in userdata:

- yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
- yum install -y mysql-community-client.x86_64

But after logging-in to the EC2, I found that I cannot execute certain commands like

mysqldump
mysql

I checked in /usr/bin and found that mysql, mysqldump, mysqlcheck and other mysql related commands are not there.

At last I checked the system log and cloud-init log of the EC2 server and found below log:

[   75.069708] cloud-init[2691]: Installing:
[   75.071941] cloud-init[2691]: mysql-community-client         x86_64 8.0.28-1.el7     mysql80-community  53 M
[   75.076458] cloud-init[2691]: mysql-community-libs           x86_64 8.0.28-1.el7     mysql80-community 4.7 M
[   75.096330] cloud-init[2691]: replacing  mariadb-libs.x86_64 1:5.5.68-1.amzn2
[   75.099727] cloud-init[2691]: mysql-community-libs-compat    x86_64 8.0.28-1.el7     mysql80-community 1.2 M
[   75.104188] cloud-init[2691]: replacing  mariadb-libs.x86_64 1:5.5.68-1.amzn2
[   75.107629] cloud-init[2691]: Installing for dependencies:
[   75.110473] cloud-init[2691]: mysql-community-client-plugins x86_64 8.0.28-1.el7     mysql80-community 5.7 M
[   75.116311] cloud-init[2691]: mysql-community-common         x86_64 8.0.28-1.el7     mysql80-community 630 k
[   75.116510] cloud-init[2691]: ncurses-compat-libs            x86_64 6.0-8.20170212.amzn2.1.3
[   75.116976] cloud-init[2691]: amzn2-core        308 k
[   75.117416] cloud-init[2691]: Transaction Summary
[   75.117888] cloud-init[2691]: ================================================================================
[   75.118345] cloud-init[2691]: Install  3 Packages (+3 Dependent packages)
[   75.118801] cloud-init[2691]: Total download size: 65 M
[   75.119227] cloud-init[2691]: Downloading packages:
[   75.393593] cloud-init[2691]: warning: /var/cache/yum/x86_64/2/mysql80-community/packages/mysql-community-client-plugins-8.0.28-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
[   75.399647] cloud-init[2691]: Public key for mysql-community-client-plugins-8.0.28-1.el7.x86_64.rpm is not installed
[   76.034754] cloud-init[2691]: --------------------------------------------------------------------------------
[   76.039388] cloud-init[2691]: Total                                               67 MB/s |  65 MB  00:00
[   76.043679] cloud-init[2691]: Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[   76.075984] cloud-init[2691]: Importing GPG key 0x5072E1F5:
[   76.078955] cloud-init[2691]: Userid     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
[   76.082649] cloud-init[2691]: Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
[   76.085875] cloud-init[2691]: Package    : mysql80-community-release-el7-1.noarch (installed)
[   76.089472] cloud-init[2691]: From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[   76.093229] cloud-init[2691]: Public key for mysql-community-client-8.0.28-1.el7.x86_64.rpm is not installed
[   76.097724] cloud-init[2691]: Failing package is: mysql-community-client-8.0.28-1.el7.x86_64
[   76.101487] cloud-init[2691]: GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

How I can resolve this issue? Please suggest.

Update: The instance is: Amazon Linux 2

User Data:

Fn::Base64: !Sub |
                #cloud-config
                repo_update: true

                write_files:
                  - content: |
                        REGION=${Region}
                        ENV=${Env}
                    path: /etc/environment
                    append: true
                  - content: "${EFSFileSystem}:/ /efs efs defaults,_netdev 0 0"
                    path: /etc/fstab
                    append: true

                packages:
                  - amazon-efs-utils
                  - jq
                  - nfs-utils
                  - ruby
                  - unzip
                  - wget
                package_update: true
                package_upgrade: true

                runcmd:
                  - [ mkdir, /efs ]
                  - [ mount, /efs ]
                  - [ sh, -c, "amazon-linux-extras install -y nginx1.12 php7.4" ]
                  - yum install -y php-opcache php-gd php-mbstring php-pecl-zip php-xml
                  - yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
                  - yum install -y mysql-community-client.x86_64
                  - wget -q https://s3.amazonaws.com/amazoncloudwatch-agent/linux/amd64/latest/AmazonCloudWatchAgent.zip -O /tmp/AmazonCloudWatchAgent.zip
                  - unzip -d /tmp/AmazonCloudWatchAgentInstaller /tmp/AmazonCloudWatchAgent.zip
                  - rpm -ivh /tmp/AmazonCloudWatchAgentInstaller/amazon-cloudwatch-agent.rpm
                  - /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:${CloudwatchConfigSsm} -s
                  - wget -q https://aws-codedeploy-ap-northeast-1.s3.ap-northeast-1.amazonaws.com/latest/install -O /tmp/aws-codedeploy-install.rb
                  - [ ruby, /tmp/aws-codedeploy-install.rb, auto ]
                  - systemctl enable nginx
                  - service codedeploy-agent start
0 Answers
Related