You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.4 KiB
55 lines
1.4 KiB
|
3 months ago
|
@echo off
|
||
|
|
chcp 65001 >nul
|
||
|
|
echo ==========================================
|
||
|
|
echo 启动 PostgreSQL 数据库 (Docker)
|
||
|
|
echo ==========================================
|
||
|
|
echo.
|
||
|
|
|
||
|
|
REM 检查 Docker 是否安装
|
||
|
|
docker --version >nul 2>&1
|
||
|
|
if errorlevel 1 (
|
||
|
|
echo [错误] Docker 未安装,请先安装 Docker Desktop
|
||
|
|
exit /b 1
|
||
|
|
)
|
||
|
|
|
||
|
|
REM 启动 PostgreSQL
|
||
|
|
echo 正在启动 PostgreSQL 容器...
|
||
|
|
docker run -d \
|
||
|
|
--name market_data_postgres \
|
||
|
|
-e POSTGRES_USER=postgres \
|
||
|
|
-e POSTGRES_PASSWORD=postgres123 \
|
||
|
|
-e POSTGRES_DB=marketdata \
|
||
|
|
-p 5432:5432 \
|
||
|
|
-v postgres_data:/var/lib/postgresql/data \
|
||
|
|
--restart unless-stopped \
|
||
|
|
postgres:15-alpine
|
||
|
|
|
||
|
|
if errorlevel 1 (
|
||
|
|
echo [提示] 容器可能已存在,尝试启动现有容器...
|
||
|
|
docker start market_data_postgres
|
||
|
|
)
|
||
|
|
|
||
|
|
echo.
|
||
|
|
echo [提示] 等待数据库初始化...
|
||
|
|
timeout /t 3 /nobreak >nul
|
||
|
|
|
||
|
|
echo.
|
||
|
|
echo ==========================================
|
||
|
|
echo 数据库启动成功!
|
||
|
|
echo ==========================================
|
||
|
|
echo.
|
||
|
|
echo 连接信息:
|
||
|
|
echo - 主机: localhost
|
||
|
|
echo - 端口: 5432
|
||
|
|
echo - 数据库: marketdata
|
||
|
|
echo - 用户名: postgres
|
||
|
|
echo - 密码: postgres123
|
||
|
|
echo.
|
||
|
|
echo 常用命令:
|
||
|
|
echo - 停止: docker stop market_data_postgres
|
||
|
|
echo - 启动: docker start market_data_postgres
|
||
|
|
echo - 删除: docker rm -f market_data_postgres
|
||
|
|
echo - 连接: docker exec -it market_data_postgres psql -U postgres -d marketdata
|
||
|
|
echo.
|
||
|
|
pause
|