导读 | mariadb数据库管理系统是mysql的一个分支,主要由开源社区在维护,采用gpl授权许可 mariadb的目的是完全兼容mysql,包括api和命令行,使之能轻松成为mysql的代替品。在存储引擎方面,使用xtradb(英语:xtradb)来代替mysql的innodb。 mariadb由mysql的创始人michael widenius(英语:michael widenius)主导开发,他早前曾以10亿美元的价格,将自己创建的公司mysql ab卖给了sun,此后,随着sun被甲骨文收购,mysql的所有权也落入oracle的手中。mariadb名称来自michael widenius的女儿maria的名字。 |
获取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] |
拉去maridb的最新镜像
root@debian1:~/nginx# docker pull? mariadb |
using default tag: latest |
latest: pulling from library/mariadb |
启动,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 |
链接docker的mysql
root@debian1:~/nginx# mysql -uroot -phanye131 -h127.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 distribution尊龙凯时 copyright (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容器之内来授权链接
链接到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
登录mariadb之内
root@debian1:~/nginx# docker exec -it 255650e5e83d bash |
root@255650e5e83d:/# |
授权mysql的root用户的链接权限(其通用户同样设置)
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) |
再次链接mysql即可