-> 点击mysql的 “Create” 按钮.
kitematic利用docker下载mysql的镜像
点击右侧"Setting" 按钮, 在"Environment Variables" 里添加一项新的"MYSQL_ROOT_PASSWORD"属性, 给上值即可.如下图:
->点击Start按钮,可以通过"EXEC"在图形界面上面的左端部分可以看见查看数据库启动是否成功: “mysql -p root -u 1234”
-> 通过Docker Terminal,执行"docker ps"查看是否mysql启动成功.
docker安装的mysql镜像有一些问题总结一下子
windows下的mysql下载完要自己写一个my.ini配置文件,而winndows上实际是用虚拟机的docker,不能把配置文件复制粘贴上去的,所以要手动写个文件然后创建进去
# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
group_concat_max_len=102400
配置如上图所示,复制命令如下
docker cp 【CONTAINER ID】:【路径】文件名 【宿主机的绝对路径+文件名】
docker cp cf92087e9e9c:/usr/mysql/wh.sql /usr/wh.sql
mysql用的是navicat连接,这边连接是
所以virtualbox上也要改一改哦
设置->网络->高级->端口转发->子端口系统改陈32806
https://www.jianshu.com/p/b8bb66efff40
navicat连接docker容器中mysql遇到问题可以看一下上面链接
这个链接里面教程可以吧端口设置成固定值
docker run --name mingxie-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=1234 -d mysql:5.7
–name 后面的是docker容器名
-p 32xxx:3306 这里需要注意 32xxx
是你**链接mysql的时候的Port
。
-e MYSQL_ROOT_PASSWORD 是设置mysql的root账号密码
-d mysql 是你的镜像标签