MAC电脑docker容器中启动mysql的方法

来自:互联网
时间:2020-04-30
阅读:

MAC电脑docker容器中启动<a href=https://www.freexyz.cn/tag/MySQL.html target=_blank class=infotextkey>MySQL</a>的方法

docker下载镜像

docker pull mysql
docker images

创建容器

docker run -d -e MYSQL_ROOT_PASSWORD=root --name mysql57 -v /usr/local/docker_mysql/57/data/mysql:/var/lib/mysql -p 3306:3306 mysql --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --lower_case_table_names=1
docker exec -it mysql57 bash

如果连接Docker启动的mysql出现报错:

ERROR 2059 (HY000): Authentication plugin caching_sha2_password’ cannot be loaded

解决办法

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
SELECT plugin FROM mysql.user WHERE User = 'root';

停止

docker stop mysql

启动

docker start msyql
返回顶部
顶部