docker search mysql
docker pull mysql:5.7
docker run -d --name mysql
–privileged=true
-p 3306:3306
-e MYSQL_ROOT_PASSWORD=123456
-v /etc/mysql:/etc/mysql
-v /opt/mysql:/var/lib/mysql
-v /etc/localtime:/etc/localtime
docker.io/mysql:5.7
docker exec -it mysql bin/bash
mysql -uroot -p123456
GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘’;
打开阿里云 开放3306端口
授权远程登录
grant all privileges on . to root@’%’ identified by ‘wangjing*’;
解决SQL 分组报错
SET sql_mode=(SELECT REPLACE(@@sql_mode,‘ONLY_FULL_GROUP_BY’,’’));
set @@global.sql_mode
=‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION’;
修改完成后 需要重启spring 项目
查询系统时间
timedatectl
linux 系统时区是UTC,而mysql使用的是系统时区 所以也是UTC
进去docker容器 修改时区
进入mysql容器,连接文件,退出mysql容器,重启mysql(一鼓作气)
docker exec -it mysql bash
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
exit
docker restart mysql