• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to Run MySQL container by Docker on Rocky Linux 8.6

  • 00:22 cat /etc/os-release
  • 00:40 systemctl status docker.service
  • 00:57 docker pull mysql/mysql-server:latest
  • 01:48 docker images
  • 02:02 docker run -p 3307:3307 -d --name=mysqls
  • 02:55 docker ps
  • 03:10 docker exec -it mysqls bash
  • 03:31 mysql -u root
  • 03:53 docker logs mysqls
  • 04:04 show databases;
  • 04:27 ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
  • 04:50 create database linuxhelp;
  • 05:27 exit
{{postValue.id}}

To run MySQL container by Docker on Rocky Linux 8.6

A Docker container image is a lightweight, standalone, executable package and MySQL is the most widely adopted open source relational database.

Installation Procedure:

Step 1: Check the OS version by using the below command

[root@linuxhelp ~]# cat /etc/os-release 
NAME="Rocky Linux"
VERSION="8.6 (Green Obsidian)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="8.6"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Rocky Linux 8.6 (Green Obsidian)"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:rocky:rocky:8:GA"

Step 2: Check the Docker status by using the below command

[root@linuxhelp ~]# systemctl status docker.service 
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Fri 2022-07-22 02:35:59 EDT; 1 months 4 days ago
     Docs: https://docs.docker.com
 Main PID: 43049 (dockerd)
    Tasks: 9
   Memory: 47.0M
   CGroup: /system.slice/docker.service
           └─43049 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Step 3: Pull the MySQL Docker Image by using the below command

[root@linuxhelp ~]# docker pull mysql/mysql-server:latest
latest: Pulling from mysql/mysql-server
cdd8b07c6082: Pull complete 
c2f1720beca1: Pull complete 
39f143a8d6de: Pull complete 
118a8285b641: Pull complete 
b45cbcaf75c7: Pull complete 
d4574372e600: Pull complete 
1f565a3cbc52: Pull complete 
Digest: sha256:e30a0320f2e3c7b7ee18ab903986ada6eb1ce8e5ef29941b36ec331fae5f10b2
Status: Downloaded newer image for mysql/mysql-server:latest
docker.io/mysql/mysql-server:latest

Step 4: List the Docker images by using the below command

[root@linuxhelp ~]# docker images
REPOSITORY           TAG       IMAGE ID       CREATED         SIZE
mysql/mysql-server   latest    eb5713a2c247   4 weeks ago     428MB
hello-world          latest    feb5d9fea6a5   11 months ago   13.3kB

Step 5: Run the MySQL image by using the below command

[root@linuxhelp ~]# docker run -p 3307:3307 -d --name=mysqls mysql/mysql-server:latest
a7818c8489a2a226b02ce66155eb9693377beb693491ad258a4a7ef784552687

Step 6: Now check MySQL Docker Container by using the below command

[root@linuxhelp ~]# docker ps
CONTAINER ID   IMAGE                       COMMAND                  CREATED          STATUS                             PORTS                                                                  NAMES
a7818c8489a2   mysql/mysql-server:latest   "/entrypoint.sh mysq…"   16 seconds ago   Up 14 seconds (health: starting)   3306/tcp, 33060-33061/tcp, 0.0.0.0:3307->3307/tcp, :::3307->3307/tcp   mysqls

Step 7: Execute the MySQL container by using bash shell

[root@linuxhelp ~]# docker exec -it mysqls bash 

Step 8: Get MySQL root password from Docker MySQL log files using the below command

[root@linuxhelp ~]# docker logs mysqls
[Entrypoint] MySQL Docker Image 8.0.30-1.2.9-server
[Entrypoint] No password option specified for new database.
[Entrypoint]   A random onetime password will be generated.
2022-08-26T03:10:32.817870Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 
2022-08-26T03:10:32.817929Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.30) initializing of server in progress as process 16
[Entrypoint] Initializing database
2022-08-26T03:10:39.984183Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock
[Entrypoint] GENERATED ROOT PASSWORD: r8#f*:&J8bezPS1y2Kl8?:mA8P?31G:B

Step 9: Login MySQL as root user by using the below command

bash-4.4# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.30
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Step 10: Next, change the MySQL root server password by using the below command

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
Query OK, 0 rows affected (0.03 sec)

Step 11: Check the MySQL databases by using the below command

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.05 sec)

Step 12: Create the MySQL databases by using the below command

mysql> create database linuxhelp;
Query OK, 1 row affected (0.01 sec)

mysql> use linuxhelp;
Database changed

Step 13: Exit MySQL

mysql> exit
Bye

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to run MySQL container by docker on rocky Linux 8.6. Your feedback is much welcome.

Tags:
samson
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

What is the LAMP?

A

The LAMP is a platform used for web development. The Lamp uses Linux, Apache, MySQL, and PHP as an operating system, web server, database & object-oriented scripting language. And hence abbreviated as LAMP.

Q

What Is the Default MySQL Port Number?

A

The default MySQL port is 3306

Q

What is Docker Engine?

A

Docker daemon or Docker engine represents the server. The docker daemon and the clients should be run on the same or remote host, which can communicate through command-line client binary and full RESTful API.

Q

What command should you run to see all running containers in Docker?

A

Use following commands $ docker ps

Q

What is a Docker hub?

A

Docker hub is a cloud-based registry that helps you to link to code repositories. It allows you to build, test, and store your image in the Docker cloud.

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Gibbson ?
How do i run both nginx and apache in same instance on centos

Hi...,

my server is based centos operating system and my webserver is already running on Apache.... i need to run both apache and nginx on same instance ... please help me to implement this concept...

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.