如何在Windows上启动PostgreSQL?
我已在Windows 10 PC上安装了Postgresql.我已经使用pgAdmin II工具创建了一个名为company的数据库,现在我想启动运行的数据库服务器.我不知道该怎么做. 我已经在postgres命令行上运行了start命令,似乎什么也没发生.
I have installed Postgresql on my Windows 10 PC. I have used the pgAdmin II tool to create a database called company, and now I want to start the database server running. I cannot figure out how to do this. I have run the start command on the postgres command line, and nothing seems to happen.
我在做什么:
postgres=# pg_ctl start
postgres=# pg_ctl status
postgres=# pg_ctl restart
postgres=# pg_ctl start company
postgres=# pg_ctl status
.....->我什么也没回来.
.....-> I am seeing nothing returned.
pg_ctl
是命令行(Windows)程序,不是 SQL语句.您需要从cmd.exe
进行操作.或使用net start postgresql-9.5
pg_ctl
is a command line (Windows) program not a SQL statement. You need to do that from a cmd.exe
. Or use net start postgresql-9.5
如果通过安装程序安装了Postgres,则应启动Windows 服务,而不要手动运行pg_ctl
,例如使用:
If you have installed Postgres through the installer, you should start the Windows service instead of running pg_ctl
manually, e.g. using:
net start postgresql-9.5
请注意,服务名称在您的安装中可能会有所不同.另一种选择是通过Windows控制面板启动服务
Note that the name of the service might be different in your installation. Another option is to start the service through the Windows control panel
我已经使用pgAdmin II工具创建了一个名为company
这意味着Postgres已经在运行,所以我不明白为什么您认为您需要再次执行该操作.特别是因为安装程序通常会将服务设置为在Windows启动时自动启动.
Which means that Postgres is already running, so I don't understand why you think you need to do that again. Especially because the installer typically sets the service to start automatically when Windows is started.
您看不到任何结果的原因是psql
要求每个 SQL 命令以;
终止,这只是在等待您完成语句.
The reason you are not seeing any result is that psql
requires every SQL command to be terminated with ;
in your case it's simply waiting for you to finish the statement.
有关更多详细信息,请参见此处:在psql中,为什么要这样做有些命令没有效果?
See here for more details: In psql, why do some commands have no effect?