Sharing Ilmu

Sharing for useful things

How To running Database server with container on linux CentOS/RedHat

In this tutorial, I’ll explain step by step about configuration for running database server on container in linux centos/redhat.

For can use the mysql command, make sure the mysql packages have installed in your system.

If not installed, you can install first

$ sudo yum install mysql -y

As usually before you pull/download images from registry, login first to registry.

$ podman login registry.redhat.io

Do pull images for mariadb-103

$ podman pull registry.redhat.io/rhel8/mariadb-103

Check images from local storage

Now running container and create database with the following information :

Name : mydatabase

MYSQL USER : userdb

MYSQL PASSWORD : user123

MYSQL DATABASE : mydb

MYSQL ROOT PASSWORD : user123

Create container for database :

$ podman run -d –name mydatabase -p 3306:3306 -e MYSQL_USER=userdb -e MYSQL_PASSWORD=user123 -e MYSQL_DATABASE=mydb -e MYSQL_ROOT_PASSWORD=user123 registry.redhat.io/rhel8/mariadb-103

Then check container with podman ps command :

$ podman ps

As the shown image above, the container has been successfull to create.

Now test login to mysql service with user and password that are created with container image before. After successful login to mysql, use show databases command to showing database information.

As the shown above, there are exist mydb database that has been to create in preceding container configuration which shown the configuration of container for databases has successfull.

 

Leave a Reply

Your email address will not be published. Required fields are marked *.

*
*
You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>