Unable to use mysql server on amazonlinux:2 container

Hi Team,

We have tried to install mysql server on amazonlinux:2 container image. We unable to run the MySQL service on the container image.

  1. docker run -it amazonlinux:2 bash

  2. yum update -y && yum install mysql -y

bash-4.2# mysql --version
mysql Ver 15.1 Distrib 5.5.64-MariaDB, for Linux (x86_64) using readline 5.1

bash-4.2# systemctl start mysql.service

Failed to get D-Bus connection: Operation not permitted

https://aws.amazon.com/amazon-linux-2/release-notes/

systemd

Amazon Linux 2 provides the systemd service and systems manager (in place of System V init). As a result, applications running on Amazon Linux AMI may require changes to run on Amazon Linux 2. Amazon Elastic Compute Cloud (Amazon EC2) instances running Amazon Linux will not be upgradeable to Amazon Linux 2 through rolling upgrade mechanisms.

Amazon Linux 2 uses the systemd 219 init system to bootstrap userspace and manage system processes. It is available as /sbin/init and replaces the System V-style init system that was available in the previous generation of Amazon Linux. As a result, initscripts should no longer exist in /etc/init.d. systemctl {start|stop|restart} SERVICE_NAME.service should be used in its place. Additionally, service SERVICE_NAME {start|stop|restart} is compatible with both Amazon Linux AMI and Amazon Linux 2.

Reason for using amazonlinux:2 container image. We are planning to use amazonlinux:2 as our common container image for all our product.

Please update us here any additional info needed on this.

Thanks

Try to start it in the foreground with mysqld.

Hi

We tried suggested steps and got the below response.

bash-4.2# systemctl start mysqld.service

Failed to get D-Bus connection: Operation not permitted

bash-4.2# systemctl start mysqld.service

Failed to get D-Bus connection: Operation not permitted

Thanks

What I meant is: Don’t start a daemon, don’t use systemctl, just call mysqld and let it run in the foreground.

Hi

Tried to call mysqld and it throws mysqld command not found.

bash-4.2# mysql --version

mysql Ver 15.1 Distrib 5.5.64-MariaDB, for Linux (x86_64) using readline 5.1

bash-4.2# mysqld

bash: mysqld: command not found

Thanks

You have to use the full path. It’s probably /usr/sbin/mysqld, but you have to check it. And it probably needs some parameters like --basedir and --datadir.
Take care, mysql is the client application (the program that you use to connect to the database), not the server.