数据库
首页 > 数据库> > 0.7 docker 安装mysql8

0.7 docker 安装mysql8

作者:互联网

docker search mysql
docker pull mysql:8.0
mkdir -p /opt/docker/mysql8
[mysqld]
user=mysql
character-set-server=utf8
default_authentication_plugin=mysql_native_password
secure_file_priv=/var/lib/mysql
expire_logs_days=7
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
max_connections=1000
bind-address=0.0.0.0
default-time-zone = '+08:00'
skip-name-resolve
lower_case_table_names=1
slow_query_log =1
slow_query_log_file=/opt/docker/mysql8/slow/localhost-slow.log
long_query_time = 10
[client]
default-character-set=utf8

[mysql]
default-character-set=utf8
docker run --restart=always --privileged=true -p 3306:3306 --name mysql8 \
-v /opt/docker/mysql8/my.cnf:/etc/mysql/my.cnf \
-v /opt/docker/mysql8/conf.d:/etc/mysql/conf.d \
-v /opt/docker/mysql8/logs:/var/log/mysql \
-v /opt/docker/mysql8/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=123456 \
-d mysql

docker logs -f mysql8
docker cp /usr/share/zoneinfo/Asia/Shanghai mysql8:/etc/localtime
docker exec -it mysql8 bash
mysql -uroot -p123456
show databases;
use mysql;
select host,user from user;
grant all privileges on *.* to 'root'@'%' with grant option;
flush privileges;

标签:opt,slow,log,mysql8,0.7,mysql,docker
来源: https://blog.csdn.net/weixin_45501950/article/details/122114515