0%

MacOS M1 docker安装Mysql 5.7

拉取镜像

1
2
3
4
# 安装5.7
docker pull mysql/mysql-server:5.7
# 安装最新
docker pull mysql/mysql-server:latest

下载设置安装mysql5.7

1
docker run --restart=always --name=mysql --privileged=true -p 3306:3306 -v /Users/liuqi/home/dev/hock/docker_volumes/mysql5.7:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql/mysql-server:5.7

进入容器病修改配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
docker exec -it mysql bash

mysql -uroot -p 123456

# 修改本地root 密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';

# 创建新用户,可供外部访问
CREATE USER 'root'@'%' IDENTIFIED BY 'root';
# 授权
GRANT ALL ON *.* TO 'root'@'%';
FLUSH PRIVILEGES;

# 修改外部连接root 用户密码
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';

FLUSH PRIVILEGES;

arm64 警告

image may have poor performance,or fail, if run via emulation
在模拟环境下,性能降低, 如果不喜欢,装最新版即可。