简体   繁体   English

如何在 Mac OS X 上启动 PostgreSQL 服务器?

[英]How can I start PostgreSQL server on Mac OS X?

Final update:最终更新:

I had forgotten to run the initdb command.我忘了运行initdb命令。


By running this command通过运行此命令

ps auxwww | grep postgres

I see that postgres is not running我看到postgres没有运行

> ps auxwww | grep postgres
remcat          1789   0.0  0.0  2434892    480 s000  R+   11:28PM   0:00.00 grep postgres

This raises the question:这就提出了一个问题:

How do I start the PostgreSQL server?如何启动 PostgreSQL 服务器?

Update:更新:

> pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
server starting
sh: /usr/local/var/postgres/server.log: No such file or directory

Update 2:更新 2:

The touch was not successful, so I did this instead:触摸不成功,所以我这样做了:

> mkdir /usr/local/var/postgres
> vi /usr/local/var/postgres/server.log
> ls /usr/local/var/postgres/
server.log

But when I try to start the Ruby on Rails server, I still see this:但是当我尝试在 Rails 服务器上启动 Ruby 时,我仍然看到:

Is the server running on host "localhost" and accepting TCP/IP connections on port 5432?服务器是否在主机“localhost”上运行并接受端口 5432 上的 TCP/IP 连接?

Update 3:更新 3:

> pg_ctl -D /usr/local/var/postgres status
pg_ctl: no server running

Update 4:更新 4:

I found that there wasn't any pg_hba.conf file (only file pg_hba.conf.sample ), so I modified the sample and renamed it (to remover the.sample).我发现没有任何pg_hba.conf文件(只有文件pg_hba.conf.sample ),所以我修改了示例并将其重命名(以删除.sample)。 Here are the contents:以下是内容:

 # IPv4 local connections:
 host    all             all             127.0.0.1/32           trust
 # IPv6 local connections:
 host    all             all             ::1/128                trust

But I don't understand this:但我不明白这一点:

> pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
server starting
> pg_ctl -D /usr/local/var/postgres status
pg_ctl: no server running

Also:还:

sudo find / -name postgresql.conf
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory

Update 5:更新 5:

sudo pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
Password:
pg_ctl: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will own the server process.

Update 6:更新 6:

This seems odd:这似乎很奇怪:

> egrep 'listen|port' /usr/local/var/postgres/postgresql.conf
egrep: /usr/local/var/postgres/postgresql.conf: No such file or directory

Though, I did do this:虽然,我确实这样做了:

>sudo find / -name "*postgresql.conf*"
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/usr/local/Cellar/postgresql/9.0.4/share/postgresql/postgresql.conf.sample
/usr/share/postgresql/postgresql.conf.sample

So I did this:所以我这样做了:

egrep 'listen|port' /usr/local/Cellar/postgresql/9.0.4/share/postgresql/postgresql.conf.sample
#listen_addresses = 'localhost'        # what IP address(es) to listen on;
#port = 5432                # (change requires restart)
                # supported by the operating system:
                #   %r = remote host and port

So I tried this:所以我尝试了这个:

> cp /usr/local/Cellar/postgresql/9.0.4/share/postgresql/postgresql.conf.sample /usr/local/Cellar/postgresql/9.0.4/share/postgresql/postgresql.conf
> cp /usr/share/postgresql/postgresql.conf.sample /usr/share/postgresql/postgresql.conf

I am still getting the same "Is the server running?"我仍然得到相同的“服务器正在运行吗?” message.信息。

The Homebrew package manager includes launchctl plists to start automatically. Homebrew包管理器包含自动启动的launchctl plists。 For more information run brew info postgres . 有关更多信息,请运行brew info postgres

Start manually: 手动启动:

pg_ctl -D /usr/local/var/postgres start

Stop manually: 手动停止:

pg_ctl -D /usr/local/var/postgres stop

Start automatically: 自动启动:

"To have launchd start postgresql now and restart at login:" “要立即启动postgresql并在登录时重新启动:”

brew services start postgresql


What is the result of pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start ? pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start什么?

What is the result of pg_ctl -D /usr/local/var/postgres status ? pg_ctl -D /usr/local/var/postgres status什么?

Are there any error messages in the server.log? server.log中是否有任何错误消息?

Make sure tcp localhost connections are enabled in pg_hba.conf: 确保在pg_hba.conf中启用了tcp localhost连接:

# IPv4 local connections:
host    all             all             127.0.0.1/32            trust

Check the listen_addresses and port in postgresql.conf: 检查postgresql.conf中的listen_addresses和port:

egrep 'listen|port' /usr/local/var/postgres/postgresql.conf

#listen_addresses = 'localhost'     # what IP address(es) to listen on;
#port = 5432                # (change requires restart)

Cleaning up 打扫干净

Postgres was most likely installed via Homebrew , Fink , MacPorts or the EnterpriseDB installer. Postgres最有可能通过HomebrewFinkMacPortsEnterpriseDB安装程序安装。

Check the output of the following commands to determine which package manager it was installed with: 检查以下命令的输出以确定安装它的软件包管理器:

brew && brew list|grep postgres
fink && fink list|grep postgres
port && port installed|grep postgres

If you want to manually start and stop postgresql (installed via homebrew), the easiest way is: 如果你想手动启动和停止postgresql(通过自制软件安装),最简单的方法是:

brew services start postgresql

and

brew services stop postgresql

I had almost the exact same issue, and you cited the initdb command as being the fix. 我几乎完全相同的问题,你引用initdb命令作为修​​复。 This was also the solution for me, but I didn't see that anyone posted it here, so for those who are looking for it: 这也是我的解决方案,但我没有看到有人在这里发布,所以对于那些正在寻找它的人:

initdb /usr/local/var/postgres -E utf8

If your computer was abruptly restarted 如果您的计算机突然重新启动

First, you have to delete the file /usr/local/var/postgres/postmaster.pid Then you can restart the service using one of the many other mentioned methods depending on your install. 首先,您必须删除文件/usr/local/var/postgres/postmaster.pid然后,您可以使用许多其他提到的方法之一重新启动服务,具体取决于您的安装。

You can verify this by looking at the logs of Postgres to see what might be going on: tail -f /usr/local/var/postgres/server.log 你可以通过查看Postgres的日志来验证这一点,看看会发生什么: tail -f /usr/local/var/postgres/server.log

Another approach is using lunchy gem (a wrapper for launchctl): 另一种方法是使用lunchy gem(launchctl的包装器):

brew install postgresql
initdb /usr/local/var/postgres -E utf8
gem install lunchy

To start postgres: 开始postgres:

lunchy start postgres

To stop postgres: 停止postgres:

lunchy stop postgres

For further info refer to: " How to Install PostgreSQL on a Mac With Homebrew and Lunchy " 有关详细信息,请参阅:“ 如何使用Homebrew和Lunchy在Mac上安装PostgreSQL

Here my 2 cents: I made an alias for postgres pg_ctl and put it in .bash_profile(my postgresql version is 9.2.4, and database path is /Library/PostgreSQL/9.2/data). 这里我的2美分:我为postgres pg_ctl创建了一个别名并将其放在.bash_profile中(我的postgresql版本是9.2.4,数据库路径是/Library/PostgreSQL/9.2/data)。

alias postgres.server="sudo -u postgres pg_ctl -D /Library/PostgreSQL/9.2/data"

Launch new terminal. 推出新终端。

And then? 然后? You can start/stop your postgresql server with this: 您可以使用以下命令启动/停止postgresql服务器:

postgres.server start
postgres.server stop

The cleanest way by far to start/stop/restart postgres if you have installed it through brew is to simply unload and/or load the launchd configuration file that comes with the installation: 如果你通过brew安装了postgres,那么到目前为止最简单启动/停止/重启postgres的方法是简单地卸载和/或加载安装时附带的launchd配置文件:

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

The first line will stop postgres and the second line will start it. 第一行将停止postgres,第二行将启动它。 No need to specify any data directories etc. since everything is in that file. 无需指定任何数据目录等,因为一切都在该文件中。

To start the postgresql server: 要启动postgresql服务器:

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

to end the postgresql server: 结束postgresql服务器:

pg_ctl -D /usr/local/var/postgres stop -s -m fast

You can also create an alias via CLI to make it easier: 您还可以通过CLI创建别名以简化:

alias pg-start='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start'
alias pg-stop='pg_ctl -D /usr/local/var/postgres stop -s -m fast'

With these you can just type "pg-start" to start Postgres and "pg-stop" to shut it down. 有了这些,你可以输入“pg-start”来启动Postgres,然后输入“pg-stop”来关闭它。

For test purposes, i think PostgreSQL App is the best option! 出于测试目的,我认为PostgreSQL App是最好的选择!

Run an App, and the server is up and running. 运行应用程序,服务器已启动并正在运行。 Close the App, and the server goes down. 关闭应用程序,服务器关闭。

http://postgresapp.com/ http://postgresapp.com/

Sometimes it's just the version which you are missing, and you are scratching your head unnecessarily.有时它只是您缺少的版本,而您不必要地挠头。

If you are using a specific version of PostgreSQL, for example, PostgreSQL 10, then simply do如果您使用的是 PostgreSQL 的特定版本,例如 PostgreSQL 10,那么只需执行

brew services start postgresql@10

brew services stop postgresql@10

The normal brew services start postgresql won't work without a version if you have installed it for a specific version from Homebrew .如果您从Homebrew安装了特定版本,则正常的brew services start postgresql没有版本将无法工作。

when you install postgresql using homebrew: 当您使用自制软件安装postgresql时:

brew install postgres

at the end of the output you will see this methods to start server: 在输出结束时,您将看到此方法启动服务器:

To have launchd start postgresql at login:
    ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
Then to load postgresql now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Or, if you don't want/need launchctl, you can just run:
    postgres -D /usr/local/var/postgres

I think this is the best way. 我认为这是最好的方法。

You can add alias into your .profile for convenience. 为方便起见,您可以在.profile中添加别名。

For a quick disposable test database you can run the server in the foreground. 对于快速的一次性测试数据库,您可以在前台运行服务器。

Initialize a new postgres database in a new directory 在新目录中初始化一个新的postgres数据库

mkdir db
initdb db -E utf8
createdb public

Start the server in the foreground (ctrl-C to stop the server) 在前台启动服务器(ctrl-C停止服务器)

postgres -d db

In another shell session, connect to the server 在另一个shell会话中,连接到服务器

psql -d public

I have same problem and perform all updates from first post. 我有同样的问题,并从第一篇文章执行所有更新。 But after check log file: 但检查日志文件后:

/usr/local/var/postgres/server.log

I see true cause: 我看到了真正的原因:

FATAL:  data directory "/usr/local/var/postgres" has group or world access
DETAIL:  Permissions should be u=rwx (0700).

After change permission on this directory 在此目录上更改权限后

chmod 0700 /usr/local/var/postgres

postgres server has start. postgres服务器已启动。

Everytime check log file. 每次检查日志文件。

If you didn't install it with Homebrew and directly from the Mac package, this worked for me for PostgreSQL 12 when using all the default locations, variables, etc.如果您没有使用Homebrew直接从 Mac package 安装它,那么在使用所有默认位置、变量等时,这对 PostgreSQL 12 有效。

$ sudo su postgres
bash-3.2$ /Library/PostgreSQL/12/bin/pg_ctl -D /Library/PostgreSQL/12/data/ stop

这个答案的变化: https//stackoverflow.com/a/13103603/2394728

initdb `brew --prefix`/var/postgres/data -E utf8`` &&  pg_ctl -D /usr/local/var/postgres/data -l logfile start

PostgreSQL is integrated in Server.app available through the App Store in Mountain Lion. PostgreSQL集成在Server.app中,可通过Mountain Lion的App Store获得。 That means that it is already configured, and you only need to launch it, and then create users and databases. 这意味着它已经配置,您只需要启动它,然后创建用户和数据库。

Tip : Do not start with defining $PGDATA and so on, take file locations as is. 提示 :不要从定义$ PGDATA等开始,按原样获取文件位置。

You would have this file: /Library/Server/PostgreSQL/Config/org.postgresql.postgres.plist 你会有这个文件: / Library/Server/PostgreSQL/Config/org.postgresql.postgres.plist

To start: 开始:

sudo serveradmin start postgres

Process started with arguments: 流程以参数开头:

/Applications/Server.app/Contents/ServerRoot/usr/bin/postgres_real -D /Library/Server/PostgreSQL/Data -c listen_addresses=127.0.0.1,::1 -c log_connections=on -c log_directory=/Library/Logs/PostgreSQL -c log_filename=PostgreSQL.log -c log_line_prefix=%t -c log_lock_waits=on -c log_statement=ddl -c logging_collector=on -c unix_socket_directory=/private/var/pgsql_socket -c unix_socket_group=_postgres -c unix_socket_permissions=0770 /Applications/Server.app/Contents/ServerRoot/usr/bin/postgres_real -D / Library / Server / PostgreSQL / Data -c listen_addresses = 127.0.0.1,:: 1 -c log_connections = on -c log_directory = / Library / Logs / PostgreSQL -c log_filename = PostgreSQL.log -c log_line_prefix =%t -c log_lock_waits = on -c log_statement = ddl -c logging_collector = on -c unix_socket_directory = / private / var / pgsql_socket -c unix_socket_group = _postgres -c unix_socket_permissions = 0770

You can sudo: 你可以sudo:

sudo -u _postgres psql template1

Or connect: 或连接:

psql -h localhost -U _postgres postgres

You can find the data directory, version, running status and so forth with 您可以使用找到数据目录,版本,运行状态等

sudo serveradmin fullstatus postgres  

For development purposes, one of the simplest ways is to install Postgres.app from the official site . 出于开发目的,最简单的方法之一是从官方站点安装Postgres.app。 It can be started/stopped from Applications folder or using the following commands in terminal: 它可以从Applications文件夹启动/停止,也可以在终端中使用以下命令:

# start
open -a Postgres

# stop
killall Postgres
killall postgres
   # remove old database files (If there was any)
   $rm -rf /usr/local/var/postgres    # install the binary

    $ brew install postgresql

    # init it
    $ initdb /usr/local/var/postgres

    # start the postgres server
    $ postgres -D /usr/local/var/postgres

    # create your database
    $ createdb mydb


    # Access db.
    $ psql mydb
    psql (9.0.1)
    Type "help" for help.

If you have installed using brew, below command should be enough. 如果您已经使用brew安装,则下面的命令就足够了。

brew services restart postgresql

And this sometimes might not work, in that case below two commands should definitely work 这有时可能不起作用,在这种情况下,下面两个命令肯定会起作用

rm /usr/local/var/postgres/postmaster.pid

pg_ctl -D /usr/local/var/postgres start

Homebrew is the way!!自制才是王道!!

To start the service:启动服务:

brew services start postgresql

To list it:列出它:

brew services list | grep postgres

To stop the service:要停止服务:

brew services stop postgresql

If you didn't install the Postgres server with Homebrew or installed using.dmg file, try this:如果您没有使用 Homebrew 安装 Postgres 服务器或使用 .dmg 文件安装,请尝试以下操作:

$ sudo su postgres
bash-3.2$ /Library/PostgreSQL/13/bin/pg_ctl -D /Library/PostgreSQL/13/data/ stop

having installed Postgres with homebrew that is what I do to start postgres and keep it in foreground to see the logs:使用homebrew安装了 Postgres,这就是我启动 postgres 并将其保持在前台以查看日志的方法:

/opt/homebrew/opt/postgresql/bin/postgres -D /opt/homebrew/var/postgres

$ brew upgrade postgres

fixed it for me. 为我修好了。

That, of course, will upgrade your postgres version and update/install any dependencies. 当然,这将升级您的postgres版本并更新/安装任何依赖项。 WARNING: Do this knowing that your postgresql version will likely change. 警告:知道你的postgresql版本可能会改变,这样做。 For me, that wasn't a big deal. 对我来说,这不是什么大问题。

none of the above answers fixed the issue for me despite getting the same error messages. 尽管得到了相同的错误消息,上述答案都没有为我解决问题。 I was able to get my instance back up and running by deleting the existing postmaster.pid file which was locked and not allowing connections. 通过删除已锁定且不允许连接的现有postmaster.pid文件,我能够恢复并运行我的实例。

For macports, just use the load/unload command and the port name of the running server: 对于macport,只需使用load / unload命令和正在运行的服务器的端口名称:

sudo port load postgresql96-server
- or -
sudo port unload postgresql96-server

so you don't have to remember where the /Library/LaunchDaemons/org.macports.postgresql96.plist file is located 所以你不必记住/Library/LaunchDaemons/org.macports.postgresql96.plist文件的位置

docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres

https://hub.docker.com/_/postgres

If you installed Postgres using EnterpriseDB installer then what @Kenial suggested is the way to go. 如果你使用EnterpriseDB安装程序安装Postgres,那么@Kenial建议的是要走的路。

sudo -u postgres pg_ctl -D /Library/PostgreSQL/{version}/data start
sudo -u postgres pg_ctl -D /Library/PostgreSQL/{version}/data stop

After doing brew services restart postgresql.完成 brew services 后重启 postgresql。

It works best to: brew services stop postgresql brew postgresql-upgrade-database brew services start postgresql最好的方法是: brew services stop postgresql brew postgresql-upgrade-database brew services start postgresql

Then type: psql然后输入:psql

it now runs this was after the error: psql: error: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?它现在运行这是在错误之后:psql:错误:无法连接到服务器:没有这样的文件或目录服务器是否在本地运行并接受 Unix 域套接字“/tmp/.s.PGSQL.5432”上的连接?

The upgrade may be optional depending on the other dependencies your running.升级可能是可选的,具体取决于您运行的其他依赖项。

Which means that rather than Restart using brew for in on mac os, Stop completely postgres and then start postgres and connect to your psql databaseName.这意味着不是在 mac os 上使用 brew for in 重新启动,而是完全停止 postgres,然后启动 postgres 并连接到您的 psql databaseName。

Hope this was useful.希望这很有用。

For Mac/OSX, I really like LaunchRocket for this and other background services I used in development. 对于Mac / OSX,我真的很喜欢LaunchRocket这个以及我在开发中使用的其他后台服务。

https://github.com/jimbojsb/launchrocket https://github.com/jimbojsb/launchrocket

This site has nice instructions on installation: http://macappstore.org/launchrocket/ 这个网站有很好的安装说明: http//macappstore.org/launchrocket/

This gives you a nice screen in your System Preferences that allows you to launch, reboot, root, launch at login. 这为您在系统偏好设置中提供了一个漂亮的屏幕,允许您在登录时启动,重新启动,root,启动。

This worked for me every time, inspired by Craig Ringer: 每次都受到Craig Ringer的启发,这对我有用:

brew install proctools
sudo pkill -u postgres

proctools includes pkill. proctools包括pkill。 If you don't have Brew: https://brew.sh/ 如果您没有Brew: https//brew.sh/

For completeness sake: Check whether you're inside a Tmux or Screen instance, starting won't work from there. 为了完整起见:检查您是否在TmuxScreen实例中,启动将无法在那里工作。

From: https://superuser.com/questions/879640/error-while-trying-to-start-postgres-installed-via-homebrew-operation-not-permi/898585 来自: https//superuser.com/questions/879640/error-while-trying-to-start-postgres-installed-via-homebrew-operation-not-permi/898585

This solved it for me. 这解决了我。

There is some edge case that maybe will be helpfull for someone: 有一些边缘案例可能会对某人有所帮助:

There is option, that you will have postgres.pid filled with some PID. 有选项,你将postgres.pid填充一些PID。 But if your restart your machine, and before postgress will be back again, some other process will take that PID. 但是如果你重新启动你的机器,并且在postgress再次返回之前,其他一些进程将采用该PID。 If that will happen, both pg_ctl status and brew service asked about postgres status, will tell you that it is UP. 如果发生这种情况,pg_ctl status和brew服务都会询问postgres状态,会告诉你它是UP。 Just ps aux | 只是ps aux | grep and check if it is really postgress grep并检查它是否真的是postgress

that worked for me (macOS 10.13) sudo -u postgres /Library/PostgreSQL/9.6/bin/pg_ctl start -D /Library/PostgreSQL/9.6/data 对我有用(macOS 10.13) sudo -u postgres /Library/PostgreSQL/9.6/bin/pg_ctl start -D /Library/PostgreSQL/9.6/data

or first cd /Library/PostgreSQL/9.6/bin/ 或者第一个cd /Library/PostgreSQL/9.6/bin/

I was facing the same problem.我面临着同样的问题。 I tried all of these solutions, but none worked.我尝试了所有这些解决方案,但都没有奏效。

I finally managed to get it working by changing the PostgreSQL HOST in Django settings from localhost to 127.0.0.1 .我终于设法通过将Django设置中的 PostgreSQL HOSTlocalhost更改为127.0.0.1来使其工作。

There are two primary components to PostgreSQL: the database server and a client. PostgreSQL 有两个主要组件:数据库服务器和客户端。

There is an included client via the CLI, or like me, you might be used to tools like phpMyAdmin , so it requires a separate GUI client.通过 CLI 包含一个客户端,或者像我一样,您可能习惯于phpMyAdmin之类的工具,因此它需要一个单独的 GUI 客户端。

For example, on macOS: install Postgres.app which is ~65 MB from: https://postgresapp.com/例如,在 macOS 上:安装大约 65 MB 的Postgres.app ,来自: https://postgresapp.com/

Then follow these instructions :然后按照以下说明进行操作

  • install and initialise the server with the button on the right.使用右侧的按钮安装和初始化服务器。
  • update your $PATH using terminal: sudo mkdir -p /etc/paths.d && echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp使用终端更新您的$PATHsudo mkdir -p /etc/paths.d && echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp sudo mkdir -p /etc/paths.d && echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp
  • and finally, install the pgAdmin GUI which is about ~100 MB from: https://www.pgadmin.org/download/pgadmin-4-macos/最后,安装大约 100 MB 的pgAdmin GUI: https://www.pgadmin.org/download/pgadmin-4-macos/

Here the user that is executing the command is not a Postgres user.这里执行命令的用户不是 Postgres 用户。 Because of that most people face Permission denied problem因此,大多数人面临Permission denied问题

> ./pg_ctl -D /Library/PostgreSQL/<version>/data start 
  pg_ctl: could not open PID file "/Library/PostgreSQL/<version>/data/postmaster.pid": Permission denied 

You have to switch to Postgres user and then need to execute the command您必须切换到 Postgres 用户,然后需要执行命令

sudo -u postgres ./pg_ctl start -D /Library/PostgreSQL/<version>/data/ 
sudo -u postgres ./pg_ctl stop -D /Library/PostgreSQL/<version>/data/
sudo -u postgres ./pg_ctl reload -D /Library/PostgreSQL/<version>/data/ 

Here is an easy and always forking solution (mac os):这是一个简单且始终分叉的解决方案(mac os):

(WARNING: IT WILL DELETE ALL YOUR DATABASES) (警告:它将删除您的所有数据库)

  1. Stop the postgres service:停止 postgres 服务:

    brew services stop postgres酿造服务停止 postgres

  2. Delete all files in "postgres" directory:删除“postgres”目录中的所有文件:

    rm -rf /usr/local/var/postgres/* rm -rf /usr/local/var/postgres/*

  3. Initialize the new database system:初始化新的数据库系统:

    initdb /usr/local/var/postgres -E utf8 initdb /usr/local/var/postgres -E utf8

  4. Start postgres:启动 postgres:

    pg_ctl -D /usr/local/var/postgres -l server.log start pg_ctl -D /usr/local/var/postgres -l server.log start

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM