【虚拟化docker】(二)--- 使用 docker 软件安装数据库环境


【虚拟化docker】(二)— 使用 docker 软件安装数据库环境


本文主要用于记录关于 docker 的安装数据库环境。

Docker 安装 Mysql

1. 安装 mysql

参考 Docker 安装 Mysql - 菜鸟教程

2. 启动 mysql 容器

#启动
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql

#进入容器
docker exec -it mysql bash
#登录mysql
mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

#添加远程登录用户
CREATE USER 'caosheng'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
GRANT ALL PRIVILEGES ON *.* TO 'caosheng'@'%';

3. 使用 navicat 连接 mysql

【虚拟化docker】(二)--- 使用 docker 软件安装数据库环境_第1张图片

Docker 安装 Postgres

1. 安装 Postgres

参考 docker 安装 postgres

2. 启动 Postgres 容器

#启动 //没有持久化数据
sudo docker run -d --name=postgres13 -p 5432:5432 -v postgres-volume:/var/lib/postgresql/data -e POSTGRES_PASSWORD=your_password postgres

#进入容器
sudo docker exec -it postgres13 psql -U postgres
#登录Postgres
psql -h localhost -U postgres
#修改postgres密码
ALTER USER postgres WITH PASSWORD '123456';

3. 使用 navicat 连接 Postgres

【虚拟化docker】(二)--- 使用 docker 软件安装数据库环境_第2张图片

参考文档

  • docker 安装 postgres

  • 在 Docker 中运行 PostgreSQL-csdn

  • Docker 安装 Mysql - 菜鸟教程

  • postgres 密码修改

  • 关于 Docker 的 wiki 词条链接

  • Docker 能够做什么 - csdn

  • Docker 安装 - 菜鸟教程

  • Docker 常用指令 - 知乎

感悟

相逢恨晚,再也不用为搭环境而扯皮浪费时间了

你可能感兴趣的:(虚拟化技术,#,docker,docker,数据库,postgresql)