windows--docker-指定ip启动mysql
前提条件
1默认电脑已经安装好了docker,以及自定义配置docker的网络; 2若无请参考 [链接](https://www.helloworld.net/p/8667165341)
安装
1.搜索mysql镜像
1### docker search mysql
2.拉取镜像
1### docker pull mysql
3.查看本地镜像
1### docker images
4.初次启动服务
1### docker run -d --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:latest --default-authentication-plugin=mysql_native_password
5.拷贝配置文件(注意目标地址)
1### docker cp mysql:/etc/mysql/my.cnf D:/docker/mysql/conf/
6.强制删除容器
1### docker rm -f mysql
7.修改宿主机的my.cnf文件
1# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. 2# 3# This program is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation; version 2 of the License. 6# 7# This program is distributed in the hope that it will be useful, 8# but WITHOUT ANY WARRANTY; without even the implied warranty of 9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10# GNU General Public License for more details. 11# 12# You should have received a copy of the GNU General Public License 13# along with this program; if not, write to the Free Software 14# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 16# 17# The MySQL Server configuration file. 18# 19# For explanations see 20# http://dev.mysql.com/doc/mysql/en/server-system-variables.html 21 22[mysqld] 23#表名大小写是否敏感 24lower_case_table_names=1 25 26#更改默认的身份认证插件 27default_authentication_plugin=mysql_native_password 28 29#允许导入导出 30secure-file-priv='' 31 32pid-file = /var/run/mysqld/mysqld.pid 33socket = /var/run/mysqld/mysqld.sock 34datadir = /var/lib/mysql 35secure-file-priv= NULL 36 37# Custom config should go here 38!includedir /etc/mysql/conf.d/ 39
8.重新启动一个mysql容器
1### docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -v D:/docker/mysql/data:/var/lib/mysql/ -v D:/docker/mysql/conf/my.cnf:/etc/mysql/my.cnf -v D:/docker/mysql/mysql-files:/var/lib/mysql-files/ --network zdd_docker_network --ip 172.18.0.9 -d mysql:latest
9.使用navicat客户端工具连接
10.相关配置sql
1mysql设置大小写是否敏感的一个参数。 2lower_case_table_names=0 表名存储为给定的大小和比较是区分大小写的 3lower_case_table_names = 1 表名存储在磁盘是小写的,但是比较的时候是不区分大小写 4lower_case_table_names=2 表名存储为给定的大小写但是比较的时候是小写的 5show VARIABLES like 'lower_case_table_names' 6 7查看mysql当前使用的字符集 8SHOW VARIABLES LIKE 'character_set_%'; 9 10查看版本信息 11select version() from dual; 12 13