• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to run MySQL Docker container on Debian 11.3

  • 00:33 lsb_release -a
  • 00:47 docker pull mysql/mysql-server:latest
  • 01:20 docker images
  • 01:39 docker run -p 3307:3307 -d --name=mysqls mysql/mysql-server:latest
  • 02:37 docker ps
  • 02:49 docker logs mysqls
  • 03:24 docker exec -it mysqls bash
  • 03:45 MySQL -u root -p
  • 04:10 ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
  • 04:48 show databases;
  • 04:59 create database linuxhelp;
  • 05:29 use linuxhelp;
7137

To Run MySQL Docker Container On Debian 11.3

Introduction:

The MySQL database management system is an open-source relational database management system and one of the most popular web server solutions. By storing and structuring data meaningfully, it allows easy access to it. Docker is a platform-as-a-service that supports continuous integration and continuous delivery.

Installation Procedure:

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

root@linuxhelp: ~# lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 11 (bullseye)
Release:	11
Codename:	bullseye

Step 2: Pull the Docker Image for MySQL 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 3: List the docker images by using the below command

root@linuxhelp:~# docker images

REPOSITORY           TAG       IMAGE ID       CREATED         SIZE
mysql/mysql-server   latest    eb5713a2c247   3 weeks ago     428MB
hello-world          latest    feb5d9fea6a5   11 months ago   13.3kB

Step 4: Deploy and start the MySQL container by using the below command

root@linuxhelp:~# docker run -p 3307:3307 -d --name=mysqls mysql/mysql-server:latest
5286836867a9d62a6d8f4975b48c50c1aee23d348db9319db83fbf0a00054675

Step 5: To check if the Docker MySQL Container is running or not by using the below command

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

Step 6: Take MySQL root password by 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.
[Entrypoint] Initializing database
2022-08-23T17:20:02.052268Z 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 instead.
2022-08-23T17:20:02.052384Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.30) initializing of server in progress as process 18
2022-08-23T17:20:02.058161Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-08-23T17:20:02.375951Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-08-23T17:20:03.013383Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
[Entrypoint] Database initialized
2022-08-23T17:20:07.083331Z 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 instead.
2022-08-23T17:20:07.084570Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 65
2022-08-23T17:20:07.106009Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-08-23T17:20:07.813878Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
[Entrypoint] GENERATED ROOT PASSWORD: UH;=o1Uo9jU%;lz3Gu;Bu5%687_A,I3Z

[Entrypoint] ignoring /docker-entrypoint-initdb.d/*
2022-08-23T17:20:12.271570Z 11 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.30).
2022-08-23T17:20:13.538791Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30)  MySQL Community Server - GPL.
[Entrypoint] Server shut down
[Entrypoint] Setting root user as expired. Password will need to be changed before database can be used.

[Entrypoint] MySQL init process done. Ready for start up.
[Entrypoint] Starting MySQL 8.0.30-1.2.9-server

Step 7: From the container create MySQL by using the below command

root@linuxhelp: ~# docker exec -it mysqls bash
bash-4.4#

Step 8: Login to MySQL 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 15
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 9: 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.00 sec)

Step 10: show the MySQL databases by using the below command

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

Step 11: 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
Mysql> bye;

Conclusion:

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

Tags:
muhammad
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

Is it possible to reset the Root password in MySQL?

A

yes, it is possible to reset the Root password in MySQL.

Q

How to start the MySQL Service?

A

To start the MySQL service use systemctl start mysql.

Q

How to log in to the MySQL database?

A

To login to the MySQL database use mysql -u root -p

Q

What port is MySQL?

A

Port 3306 is the default port for the classic MySQL protocol (port ), which is used by the MySQL client, MySQL Connectors, and utilities such as mysqldump and mysqlpump.

Q

What is ownCloud?

A

ownCloud is a free, open-source, and powerful web application for data synchronization, file sharing, and remote storage of files. ownCloud is written in PHP/JavaScript languages. It is designed to work with several database management systems, including MySQL, MariaDB, SQLite, Oracle Database, and PostgreSQL.

Related Tutorials in How to run MySQL Docker container on Debian 11.3

Related Tutorials in How to run MySQL Docker container on Debian 11.3

How to install Gparted on Debian 9.0
How to install Gparted on Debian 9.0
Sep 13, 2017
Installation SSL Certificate on Ubuntu/Linuxmint/Debian to Secure Apache
Installation SSL Certificate on Ubuntu/Linuxmint/Debian to Secure Apache
Sep 19, 2018
How to remove MySQL package completely on Ubuntu 16.04
How to remove MySQL package completely on Ubuntu 16.04
Apr 17, 2017
How to install and update OpenSSL on Debian 11.3
How to install and update OpenSSL on Debian 11.3
Oct 21, 2022
How To Install Mysql-Workbench On Linux Mint 20.2
How To Install Mysql-Workbench On Linux Mint 20.2
Apr 27, 2022
How to install qBittorrent on Debian 9.0
How to install qBittorrent on Debian 9.0
Sep 8, 2017
How to Install FileZilla in Debian
How to Install FileZilla in Debian
Nov 29, 2016
How to install Nmap on Debian 9.0
How to install Nmap on Debian 9.0
Sep 9, 2017

Related Forums in How to run MySQL Docker container on Debian 11.3

Related Forums in How to run MySQL Docker container on Debian 11.3

MySQL
rolando class=
Mysqldump: Couldn't execute 'SHOW VARIABLES LIKE 'gtid\_mode'': Table 'performance_schema.session_variables' doesn't exist (1146)
May 9, 2019
MySQL
isaiah class=
ERROR! MySQL is not running, but lock file (/var/lock/subsys/mysql) exists
Feb 8, 2017
MySQL
liam class=
How to check mysql history in Linux
Aug 28, 2017
MariaDB
ryan class=
E: Unable to locate package mariadb-server
Sep 18, 2017
Database
john class=
Warning: mysqli::__construct(): (HY000/2002): No route to host
May 23, 2017
CentOS Web Panel
anettejoseph class=
Centos Web Panel : How to find mysql root password
Jan 30, 2018
Linux
AadrikaAnshu class=
How to add timestamps to history On Any Linux Machine
Jun 18, 2019
MySQL
julian class=
ERROR 1881 (HY000) at line 43: Operation not allowed when innodb_forced_recovery > 0
Apr 22, 2017

Related News in How to run MySQL Docker container on Debian 11.3

Related News in How to run MySQL Docker container on Debian 11.3

Docker friendly Alpine Linux gets hardened Node.js
Docker friendly Alpine Linux gets hardened Node.js
Apr 19, 2017
SQL sequel - worm rear its head after a decade
SQL sequel - worm rear its head after a decade
Feb 8, 2017
Debian IceDove kicks the bucket after Thunderbird revisits Debian Repositories
Debian IceDove kicks the bucket after Thunderbird revisits Debian Repositories
Feb 28, 2017
Mass update of Jessie - A better alternative to new version?
Mass update of Jessie - A better alternative to new version?
May 8, 2017
Nine Popular WordPress plugins affected with critical SQL injection vulnerabilities
Nine Popular WordPress plugins affected with critical SQL injection vulnerabilities
Sep 7, 2019
Docker comes to a full circle with DIY Linux
Docker comes to a full circle with DIY Linux
Apr 20, 2017
Docker contains an unpatched rare condition vulnerability
Docker contains an unpatched rare condition vulnerability
Jun 1, 2019
GandCrab Ransomware Infection Made by Scanning MySQL Databases
GandCrab Ransomware Infection Made by Scanning MySQL Databases
May 28, 2019
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 Sebastian ?
How to change non required to required field in SuiteCRM Custom/Default Modules

How to change not required to the required field in SuiteCRM Custom/Default Modules?

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.