postgres数据库初始化、启动、停止
warning:
这篇文章距离上次修改已过424天,其中的内容可能已经有所变动。
要初始化、启动和停止PostgreSQL数据库,你可以使用以下命令:
初始化数据库:
sudo service postgresql initdb启动PostgreSQL服务:
sudo service postgresql start停止PostgreSQL服务:
sudo service postgresql stop请注意,这些命令适用于使用systemd的系统,例如最新的Ubuntu、Debian、CentOS等。如果你的系统不使用systemd,你可能需要使用其他命令,如/etc/init.d/postgresql或pg_ctl。
对于非systemd系统,使用以下命令:
启动PostgreSQL服务:
sudo /etc/init.d/postgresql start停止PostgreSQL服务:
sudo /etc/init.d/postgresql stop或者使用pg_ctl工具:
启动PostgreSQL服务:
pg_ctl start -D /path/to/postgresql/data/directory停止PostgreSQL服务:
pg_ctl stop -D /path/to/postgresql/data/directory在这里,/path/to/postgresql/data/directory是你的PostgreSQL数据目录的路径。
确保你有适当的权限来执行这些命令,否则你可能需要使用sudo。
评论已关闭