安装篇-安装mysql8
之前做过笔记用 docker-compose 安装过 mysql5.7,实际开发中有用到8.0以后的函数比如:
row_number() over ( PARTITION BY re.emp_id ) AS num
等等 ... 因此记录下安装mysql8。
1. yaml配置
version: '3.1'
services:
db:
image: mysql
container_name: mysql8
restart: always
environment:
MYSQL_ROOT_PASSWORD: 123456
command:
--default-authentication-plugin=mysql_native_password
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
--explicit_defaults_for_timestamp=true
--lower_case_table_names=1
--max_allowed_packet=128M;
ports:
- 3306:3306
volumes:
- ./data:/var/lib/mysql
2. 修改远程权限
- 1、启动容器
docker-compose up -d
- 2、进入容器
docker exec -it mysql8 /bin/bash
- 3、连接mysql
mysql -u root -p
- 4、修改远程权限
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
- 5、刷新
flush privileges;