windows--docker-指定ip启动mysql 3年前

windows--docker-指定ip启动mysql

前提条件

默认电脑已经安装好了docker,以及自定义配置docker的网络;
若无请参考 [链接](https://www.helloworld.net/p/8667165341)

安装

1.搜索mysql镜像

### docker search mysql

2.拉取镜像

### docker pull mysql

3.查看本地镜像

### docker images

4.初次启动服务

### docker run -d --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:latest --default-authentication-plugin=mysql_native_password

5.拷贝配置文件(注意目标地址)

### docker cp mysql:/etc/mysql/my.cnf D:/docker/mysql/conf/

6.强制删除容器

### docker rm -f mysql

7.修改宿主机的my.cnf文件

# Copyright (c) 2017, 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

#
# The MySQL  Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

[mysqld]
#表名大小写是否敏感
lower_case_table_names=1

#更改默认的身份认证插件
default_authentication_plugin=mysql_native_password

#允许导入导出
secure-file-priv=''

pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
secure-file-priv= NULL

# Custom config should go here
!includedir /etc/mysql/conf.d/

8.重新启动一个mysql容器

### 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

mysql设置大小写是否敏感的一个参数。
lower_case_table_names=0  表名存储为给定的大小和比较是区分大小写的
lower_case_table_names = 1  表名存储在磁盘是小写的,但是比较的时候是不区分大小写
lower_case_table_names=2 表名存储为给定的大小写但是比较的时候是小写的
show VARIABLES like 'lower_case_table_names'

查看mysql当前使用的字符集
SHOW VARIABLES LIKE 'character_set_%';

查看版本信息
select version() from dual;

人家是男孩纸哟
旧时王谢堂前燕,飞入寻常百姓家。
3
发布数
2
关注者
9071
累计阅读

热门教程文档

Vue
25小节
Rust
84小节
Objective-C
29小节
React Native
40小节
Lua
21小节
广告