{"id":77392,"date":"2023-09-01T05:43:14","date_gmt":"2023-08-31T21:43:14","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=77392"},"modified":"2023-09-01T05:43:14","modified_gmt":"2023-08-31T21:43:14","slug":"docker-build-mariadb","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/docker-build-mariadb.html","title":{"rendered":"docker\u6784\u5efaMariadb\u6570\u636e\u5e93"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nMariaDB\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u662fMySQL\u7684\u4e00\u4e2a\u5206\u652f\uff0c\u4e3b\u8981\u7531\u5f00\u6e90\u793e\u533a\u5728\u7ef4\u62a4\uff0c\u91c7\u7528GPL\u6388\u6743\u8bb8\u53ef MariaDB\u7684\u76ee\u7684\u662f\u5b8c\u5168\u517c\u5bb9MySQL\uff0c\u5305\u62ecAPI\u548c\u547d\u4ee4\u884c\uff0c\u4f7f\u4e4b\u80fd\u8f7b\u677e\u6210\u4e3aMySQL\u7684\u4ee3\u66ff\u54c1\u3002\u5728\u5b58\u50a8\u5f15\u64ce\u65b9\u9762\uff0c\u4f7f\u7528XtraDB\uff08\u82f1\u8bed\uff1aXtraDB\uff09\u6765\u4ee3\u66ffMySQL\u7684InnoDB\u3002 MariaDB\u7531MySQL\u7684\u521b\u59cb\u4ebaMichael Widenius\uff08\u82f1\u8bed\uff1aMichael Widenius\uff09\u4e3b\u5bfc\u5f00\u53d1\uff0c\u4ed6\u65e9\u524d\u66fe\u4ee510\u4ebf\u7f8e\u5143\u7684\u4ef7\u683c\uff0c\u5c06\u81ea\u5df1\u521b\u5efa\u7684\u516c\u53f8MySQL AB\u5356\u7ed9\u4e86SUN\uff0c\u6b64\u540e\uff0c\u968f\u7740SUN\u88ab\u7532\u9aa8\u6587\u6536\u8d2d\uff0cMySQL\u7684\u6240\u6709\u6743\u4e5f\u843d\u5165Oracle\u7684\u624b\u4e2d\u3002MariaDB\u540d\u79f0\u6765\u81eaMichael Widenius\u7684\u5973\u513fMaria\u7684\u540d\u5b57\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

\u83b7\u53d6mariadb\u955c\u50cf\u5730\u5740<\/strong><\/div>\n\n\n\n\n\n
root@debian1:~\/nginx# docker search mariadb
\nNAME\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 DESCRIPTION\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 STARS\u00a0\u00a0\u00a0\u00a0 OFFICIAL\u00a0\u00a0 AUTOMATED<\/td>\n<\/tr>\n
mariadb\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 MariaDB is a community-developed fork of M...\u00a0\u00a0 1417\u00a0\u00a0\u00a0\u00a0\u00a0 [OK]<\/td>\n<\/tr>\n
bitnami\/mariadb\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Bitnami MariaDB Docker Image\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 39\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 [OK]<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u62c9\u53bbmaridb\u7684\u6700\u65b0\u955c\u50cf<\/strong><\/div>\n\n\n\n\n\n
root@debian1:~\/nginx# docker pull\u00a0 mariadb<\/td>\n<\/tr>\n
Using default tag: latest<\/td>\n<\/tr>\n
latest: Pulling from library\/mariadb<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u542f\u52a8\uff0cmariadb\u955c\u50cf<\/strong><\/div>\n\n\n\n\n\n\n\n\n
root@debian1:~\/nginx# docker run\u00a0 --privileged\u00a0 -d -e TIMEZONE=Asis\/Shanghai -e MYSQL_ROOT_PASSWORD=hanye131 -e SERVER_ID=1 -v $PWD\/mysql_db:\/var\/lib\/mysql\u00a0 -p 3306:3306\u00a0 mariadb<\/td>\n<\/tr>\n
255650e5e83d27402b1df338c09c0639b1512e73ef27cd31e1f2c90509dc104c<\/td>\n<\/tr>\n
root@debian1:~\/nginx# docker ps -a<\/td>\n<\/tr>\n
CONTAINER ID\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 IMAGE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 COMMAND\u00a0 CREATED\u00a0\u00a0\u00a0\u00a0\u00a0 STATUS\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 PORTS\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 NAMES<\/td>\n<\/tr>\n
255650e5e83d\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 mariadb\u00a0\u00a0\u00a0\u00a0\u00a0 \"docker-entrypoint...\"\u00a0\u00a0 3 seconds ago\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Up 1 second\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.0.0.0:3306->3306\/tcp\u00a0\u00a0 festive_ride<\/td>\n<\/tr>\n
<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u67e5\u770b\u542f\u52a8\u5360\u7528\u7684\u7aef\u53e3<\/strong><\/div>\n\n\n\n\n
root@debian1:~\/nginx# netstat\u00a0 -tunl|grep 3306<\/td>\n<\/tr>\n
tcp6\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0 0 :::3306\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 :::*\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 LISTEN<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u94fe\u63a5docker\u7684mysql<\/strong><\/div>\n\n\n\n
root@debian1:~\/nginx# mysql -uroot -phanye131 -h127.0.0.1
\nWelcome to the MySQL monitor.\u00a0 Commands end with ; or \\g.
\nYour MySQL connection id is 8
\nServer 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
\naffiliates. Other names may be trademarks of their respective
\nowners.Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.mysql><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u9519\u8bef\u89e3\u51b3\u65b9\u6848<\/strong><\/div>\n

\u5982\u679c\u63d0\u793a\u65e0\u6cd5\u94fe\u63a5\u627e\u5230sock\u6587\u4ef6\uff0c\u4f60\u9700\u8981\u94fe\u63a5\u5230docker\u7684mariadb\u5bb9\u5668\u4e4b\u5185\u6765\u6388\u6743\u94fe\u63a5<\/p>\n

\u94fe\u63a5\u5230docker mariadb\u4e4b\u5185<\/strong><\/span><\/div>\n

\u83b7\u53d6mariadb\u7684CONTAINER ID<\/p>\n\n\n\n\n\n
root@debian1:~\/nginx# docker ps -a<\/td>\n<\/tr>\n
CONTAINER ID\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 IMAGE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 COMMAND\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 CREATED\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 STATUS\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 PORTS\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 NAMES<\/td>\n<\/tr>\n
255650e5e83d\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 mariadb\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"docker-entrypoint...\"\u00a0\u00a0 10 minutes ago\u00a0\u00a0\u00a0\u00a0\u00a0 Up 10 minutes\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.0.0.0:3306->3306\/tcp\u00a0\u00a0 festive_ride
\n360baf71efb0\u00a0\u00a0\u00a0\u00a0 a3ae0b27ec04\u00a0\u00a0\u00a0 \"\/run.sh bash\"\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 3 hours ago\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Exited (2) 3 hours ago\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 nginx<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u6211\u8fd9\u91cc\u7684mariadb\u7684\u955c\u50cf\u7684CONTAINER ID\u662f 255650e5e83d<\/p>\n

\u767b\u5f55mariadb\u4e4b\u5185<\/strong><\/span><\/div>\n\n\n\n\n
root@debian1:~\/nginx# docker exec -it 255650e5e83d bash<\/td>\n<\/tr>\n
root@255650e5e83d:\/#<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u6388\u6743mysql\u7684root\u7528\u6237\u7684\u94fe\u63a5\u6743\u9650\uff08\u5176\u901a\u7528\u6237\u540c\u6837\u8bbe\u7f6e\uff09<\/strong><\/span><\/div>\n\n\n\n\n
MariaDB [(none)]> grant all on *.* to 'root'@'192.168.1.%' identified by 'hanye131';
\nQuery OK, 0 rows affected (0.01 sec)<\/td>\n<\/tr>\n
MariaDB [(none)]> flush privileges;
\nQuery OK, 0 rows affected (0.01 sec)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u518d\u6b21\u94fe\u63a5mysql\u5373\u53ef<\/strong><\/div>\n
\n

\u539f\u6587\u6765\u81ea\uff1ahttp:\/\/blog.chinaunix.net\/uid-30234663-id-5767316.html<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1a http:\/\/lrxjmw.cn\/docker-build-mariadb.html<\/a>\u7f16\u8f91\uff1a\u90d1\u5e05\uff0c\u5ba1\u6838\u5458\uff1a\u51af\u742a<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb MariaDB\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u662fMySQL\u7684\u4e00\u4e2a\u5206\u652f\uff0c\u4e3b\u8981\u7531\u5f00\u6e90\u793e\u533a\u5728\u7ef4\u62a4\uff0c\u91c7\u7528GPL\u6388\u6743\u8bb8\u53ef Maria […]<\/p>\n","protected":false},"author":63,"featured_media":77393,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-77392","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/77392","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=77392"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/77392\/revisions"}],"predecessor-version":[{"id":281593,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/77392\/revisions\/281593"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/77393"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=77392"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=77392"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=77392"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}