安装语句
安装之前先删除原来的容器:
//停止正在运行的mysql容器
docker stop 容器名
//删除mysql容器
docker rm 容器名
安装:
docker run --name mysql -p 3306:3306 -d -v /mydata/mysql/conf/my.cnf:/etc/mysql/my.cnf -v /mydata/mysql/data:/var/lib/mysql -v /mydata/log:/logs -e MYSQL_ROOT_PASSWORD=123456 --restart=always mysql:8.0 --lower_case_table_names=1
mysql8.0的表名区分大小写,要配置成1(不区分大小写)
lower_case_table_names=1
连接报错1251- Client does not support authentication protocol requested by server…的问题
//进入容器
docker exec -it mysql /bin/bash
//登录
mysql -u root -p
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';