docker安装mysql8

docker run \
    -p 3306:3306 \
    -e MYSQL_ROOT_PASSWORD=123456 \
    -v /home/data/mysql/data:/var/lib/mysql:rw \
    -v /home/data/mysql/log:/var/log/mysql:rw \
    -v /home/data/mysql/config/my.cnf:/etc/mysql/my.cnf:rw \
    -v /etc/localtime:/etc/localtime:ro \
    --name mysql8 \
    --restart=always \
    -d mysql

修改密码

docker exec -it mysql8 /bin/sh

mysql -uroot -p
 
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';

你可能感兴趣的:(Mysql,mysql,docker)