刘明野

docker mysql8.0 授权远程登录

1.拉取镜像

docker pull mysql/mysql-server

2.运行镜像启动容器

docker run -d --name database \
    -v mysql:/var/lib/mysql \
    mysql/mysql-server

3.进入 MySQL 容器登录 MySQL

docker exec -it database mysql -uroot -p

4.创建一个用户并授权远程登录

create user 'lmy'@'%' identified by 'password';
ALTER USER 'lmy'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
flush privileges;

5.exit退出容器

参考文章:
https://hub.docker.com/r/mysql/mysql-server
https://www.cnblogs.com/tarencez/p/11841587.html
https://www.cnblogs.com/brady-wang/p/11561300.html

本文为作者刘明野发布,未经允许禁止转载!
3747
0
0
发表留言

友情链接