docker 安装mysql、redis
程序员文章站
2024-03-13 22:48:04
...
linux安装docker
#查看是否有过安装
yum list installed | grep docker
#安装
yum -y install docker
#启动
systemctl start docker
#查看状态
systemctl status docker
安装mysql
#拉取镜像
docker pull mysql:latest
#查看
docker images
#启动
docker run -itd --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql
#查看
docker ps
开启mysql远程登录
#进入容器
docker exec -it mysql bash
#登录mysql
mysql -u root -p
#添加权限
GRANT ALL ON *.* TO 'root'@'%';
#刷新
flush privileges
#查看用户信息
#备注:host为 % 表示不限制ip localhost表示本机使用 plugin非mysql_native_password 则需要修改密码
select host,user,plugin,authentication_string from mysql.user;
#修改密码
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
#刷新
flush privileges;
安装redis
#拉取镜像
docker pull redis:latest
#查看
docker images
#启动
docker run -itd --name redis -p 6379:6379 redis
#查看
docker ps