docker安装mysql8显示2013报错
问题
docker安装mysql8显示2013报错
解决
#cat docker_insert_mysql8.0.27.sh
#!/bin/sh
# Create necessary directories
mkdir -p /data/docker/mysql8.0.27/mysql
mkdir -p /data/docker/mysql8.0.27/logs
mkdir -p /data/docker/mysql8.0.27/data
mkdir -p /data/docker/mysql8.0.27/mysql-files
# Set correct permissions
chown -R 999:999 /data/docker/mysql8.0.27
# Run the MySQL container
docker run \
-p 3307:3306 \
--name mysql8 \
--privileged=true \
--restart unless-stopped \
-v /data/docker/mysql8.0.27/mysql:/etc/mysql \
-v /data/docker/mysql8.0.27/logs:/logs \
-v /data/docker/mysql8.0.27/data:/var/lib/mysql \
-v /data/docker/mysql8.0.27/mysql-files:/var/lib/mysql-files \
-v /etc/localtime:/etc/localtime:ro \
-e MYSQL_ROOT_PASSWORD=Yourpassword6567 \
-d swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/mysql:8.0.27
主要是这部分,映射到宿主机,即可
--net host \
另外需要添加mysql/conf.d/my.cnf文件
# Copyright (c) 2015, 2021, Oracle and/or its affiliates.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
# as published by the Free Software Foundation.
#
# This program is also distributed with certain software (including
# but not limited to OpenSSL) that is licensed under separate terms,
# as designated in a particular file or component or in included license
# documentation. The authors of MySQL hereby grant you an additional
# permission to link the program and your derivative works with the
# separately licensed software that they have included with MySQL.
#
# 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, version 2.0, 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 Client configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
[mysqld]
user=mysql
character-set-server=utf8
default_authentication_plugin=mysql_native_password
secure_file_priv=/var/lib/mysql
expire_logs_days=7
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
max_connections=10000
character-set-server=utf8mb4
collation-server=utf8mb4_0900_ai_ci
bind-address = 0.0.0.0
default_authentication_plugin=mysql_native_password
[client]
default-character-set=utf8mb4
[mysql]
添加mysql/conf.d/docker.cnf
[mysqld]
skip-host-cache
skip-name-resolve