MySQL contains is a prominent open-source relational database administration system and one of the popular web server solutions. It stores and structures data in a meaningful and ensures easy accessibility. A container image is maintained by the community.
Podman is a set of platform-as-a-service developments that support CI/CD development. It allows to develop and deploys applications inside virtual environments, called containers. Podman boots up an application with all its libraries and dependencies with a single image.
With podman tutorial steps previously published.
Pull 5.7 from repository
Podman checks multiple container repo so this may take a while. In this tutorial, we will use docker.io/library/mysql:5.7 since this is always available. First of all, let’s explore the containers that are available for Red Hat Enterprise Linux through the Red Hat Container Catalog (access.redhat.com/containers):
# podman pull mysql:5.7
Check mysql contains podman
So, use command podman images
# podman images
MySQL Database Instance in a Container
With all requirements met, we can create a MySQL database instance. The key Environment Variables available when running a MySQL Container are:
- MYSQL_ROOT_PASSWORD: This variable is mandatory and specifies the password set for the MySQL root superuser account.
- MYSQL_DATABASE: This is optional and allows you to specify the name of a database created on image startup.
- MYSQL_USER, MYSQL_PASSWORD: Optional and used in conjunction to create a user and to set that password.
Alternative to passing sensitive information via environment variables, _FILE may be appended to the previously listed environment variables, causing the initialization script to load the values for those variables from files present in the container.
Create the container mysql contains podman
Then, follow command as follows.
# podman run -d \ > --name mysql-5.7 \ > -p 3306:3306 \ > -v ~/mysql_data:/var/lib/mysql \ > -e MYSQL_ROOT_PASSWORD='UnixC0p.comStr0ngPass' \ > -e MYSQL_USER=unixcopdb \ > -e MYSQL_PASSWORD='unixcopdbStr0ngPass' \ > -e MYSQL_DATABASE=UnixCopDB \ > mysql:5.7 195813fd41166f2d1da893b567cb4780a075293f7231783efc95ac30a7ac0532
Then, validate the podman process if running.
Test the container if working.
# podman exec -it mysql-5.7 /bin/bash
# mysql -uroot -p'UnixC0p.comStr0ngPass'
List the databases created
So, interactive prompt to list created databases.