您好,登錄后才能下訂單哦!
這篇文章主要介紹“Docker中怎么構建Mariadb”,在日常操作中,相信很多人在Docker中怎么構建Mariadb問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”Docker中怎么構建Mariadb”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
root@debian1:~/nginx# docker search mariadb NAME DESCRIPTION STARS OFFICIAL AUTOMATED |
---|
mariadb MariaDB is a community-developed fork of M… 1417 [OK] |
bitnami/mariadb Bitnami MariaDB Docker Image 39 [OK] |
root@debian1:~/nginx# docker pull mariadb |
---|
Using default tag: latest |
latest: Pulling from library/mariadb |
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:3306 mariadb |
---|
255650e5e83d27402b1df338c09c0639b1512e73ef27cd31e1f2c90509dc104c |
root@debian1:~/nginx# docker ps -a |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
255650e5e83d mariadb “docker-entrypoint…” 3 seconds ago Up 1 second 0.0.0.0:3306->3306/tcp festive_ride |
root@debian1:~/nginx# netstat -tunl|grep 3306 |
---|
tcp6 0 0 :::3306 :::* LISTEN |
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>
如果提示無法鏈接找到sock文件,你需要鏈接到docker的mariadb容器之內來授權鏈接
獲取mariadb的CONTAINER ID
root@debian1:~/nginx# docker ps -a |
---|
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
255650e5e83d mariadb “docker-entrypoint…” 10 minutes ago Up 10 minutes 0.0.0.0:3306->3306/tcp festive_ride 360baf71efb0 a3ae0b27ec04 “/run.sh bash” 3 hours ago Exited (2) 3 hours ago nginx |
我這里的mariadb的鏡像的CONTAINER ID是 255650e5e83d
root@debian1:~/nginx# docker exec -it 255650e5e83d bash |
---|
root@255650e5e83d:/# |
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) |
到此,關于“Docker中怎么構建Mariadb”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。