利用psql启动数据库
[postgres@highgo ~]$ pg_ctl start
查看系统中运行的postgres进程
#ps -ef | grep postgres
连接postgresql数据库
#psql -h 127.0.0.1 -d postgres -U postgres
停止postgresql数据库实例
#pg_ctl stop
#ps -ef | grep postgres
启动服务器最简单的方法是像下面这样:
$ postgres -D /usr/local/pgsql/data
最好在后台启动postgres,使用下面的 Unix shell 语法:
$ postgres -D /usr/local/pgsql/data >logfile 2>&1 &
要做一次快速关闭:
$ kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`
如果启动失败提示一下信息
LOG: could not bind IPv4 socket: Address already in use
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
FATAL: could not create TCP/IP listen socket
解决方法:
查看端口在用
netstat -lanp|grep 5432
ps -ef|grep postgres
498 673 1 0 10:50 ? 00:00:00/usr/bin/postgres -D /var/lib/cloudera-scm-server-db/data
kill进程
kill -9 673
重启启动服务
service start
service status
本文介绍了如何使用psql命令行工具启动、停止PostgreSQL数据库服务,以及如何连接到数据库实例进行管理。包括了实用的Unix shell语法示例和解决启动失败问题的方法。
1万+

被折叠的 条评论
为什么被折叠?



