# pg-docker-compose **Repository Path**: changyubiao/pg-docker-compose ## Basic Information - **Project Name**: pg-docker-compose - **Description**: 方便开发本地的postgresql 的开发环境 - **Primary Language**: Docker - **License**: PostgreSQL - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-07-29 - **Last Updated**: 2024-07-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### 启动容器 docker compose up -d ### 进入容器 ```bash # 进入容器 bash docker compose exec -it postgres bash psql -h localhost -U root -d test -W #输入: root root=# select now(); ``` 连接命令介绍 `psql -h localhost -U root -d test -W` - `-h localhost` 指定数据库服务器的地址,由于你是通过端口映射在本地访问容器中的数据库,所以使用localhost。 - `-U root` 指定数据库用户名为root。 - `-d test` 指定要连接的数据库名为 test - `-W` 表示需要输入密码,接下来系统会提示你输入密码(或你设定的实际密码)。 ### 常用的一些操作 ```bash # 查看当前有哪些数据库 \l # 查看当前时间 select now(); # 退出psql 连接 \q ```