Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build Mariadb in Docker

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to build Mariadb in Docker". In daily operation, I believe many people have doubts about how to build Mariadb in Docker. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how to build Mariadb in Docker"! Next, please follow the editor to study!

Get the mariadb image address root@debian1:~/nginx# docker search mariadb NAME DESCRIPTION STARS OFFICIAL AUTOMATEDmariadb MariaDB is a community-developed fork of M... 1417 [OK] bitnami/mariadb Bitnami MariaDB Docker Image 39 [OK] pull the latest image of maridb root@debian1:~/nginx# docker pull mariadbUsing default tag: latestlatest: Pulling from library/mariadb started, mariadb image root@debian1:~/nginx# docker run-privileged-d-e TIMEZONE=Asis/Shanghai-e MYSQL_ROOT_PASSWORD=hanye131-e SERVER_ID=1-v $PWD/mysql_db:/var/lib/mysql-p 3306 mariadb255650e5e83d27402b1df338c09c0639b1512e73ef27cd31e1f2c90509dc104croot@debian1:~/nginx# docker ps-aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES255650e5e83d mariadb "docker-entrypoint …" 3 seconds ago Up 1 second 0.0.0.03306/tcp festive_ride 3306-> 3306/tcp festive_ride

View the port root@debian1:~/nginx# netstat-tunl occupied by startup | grep 3306tcp6 0 0: 3306: * mysql of LISTEN link docker

Root@debian1:~/nginx# mysql-uroot-phanye131-h227.0.0.1 Welcome to the MySQL monitor. Commands end with; or\ g. Your MySQL connection id is 8 Server version: 5.5.5-10.2.6-MariaDB-10.2.6+maria~jessie mariadb.org binary distributionCopyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.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.mysql >

Error solution

If prompted that the sock file cannot be found, you need to link to the mariadb container of docker to authorize the link

Link to within docker mariadb

Get the CONTAINER ID of mariadb

Root@debian1:~/nginx# docker ps-aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES255650e5e83d mariadb "docker-entrypoint..." 10 minutes ago Up 10 minutes 0.0.0.0 3306/tcp festive_ride 360baf71efb0 a3ae0b27ec04 3306-> 3306/tcp festive_ride 360baf71efb0 a3ae0b27ec04 "/ run.sh bash" 3 hours ago Exited (2) 3 hours ago nginx

The CONTAINER ID of my mariadb image here is 255650e5e83d.

Log in to the root user whose root@debian1:~/nginx# docker exec-it 255650e5e83d bashroot@255650e5e83d:/# authorizes mysql within the mariadb (the same is set by the user) MariaDB [(none)] > grant all on. To 'root'@'192.168.1.%' identified by' hanye131'; Query OK, 0 rows affected (0. 01 sec) MariaDB [(none)] > flush privileges; Query OK, 0 rows affected (0. 01 sec) link to mysql again, and the study on "how to build Mariadb in Docker" is over. I hope to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report