官方文档:
https://www.postgresql.org/download/macosx/

可以看到,官方推荐的是【EDB,EnterpriseDB】:

Download the installer certified by EDB for all supported PostgreSQL versions.

EnterpriseDB的PostgreSQL页面:
https://www.enterprisedb.com/products/postgresql-databases

进入下载页面:
https://www.enterprisedb.com/downloads/postgres-postgresql-downloads

下载你需要的版本:

下载完成后,在本地执行安装:

装好了以后:

然后,在命令行中查看:

adamhuan:shell/ $ ps -ef | grep postgre                                                                                                                                 [17:42:19]
  502 38224 38001   0  5:21PM ??         0:00.00 postgres: logger   
  502 38227 38001   0  5:21PM ??         0:00.01 postgres: checkpointer   
  502 38228 38001   0  5:21PM ??         0:00.03 postgres: background writer   
  502 38229 38001   0  5:21PM ??         0:00.01 postgres: walwriter   
  502 38230 38001   0  5:21PM ??         0:00.04 postgres: autovacuum launcher   
  502 38231 38001   0  5:21PM ??         0:00.20 postgres: stats collector   
  502 38232 38001   0  5:21PM ??         0:00.00 postgres: logical replication launcher   
  501 52925 21340   0  5:42PM ttys005    0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox postgre
adamhuan:shell/ $ 
adamhuan:shell/ $ netstat -an | grep 5432                                                                                                                               [17:42:48]
tcp4       0      0  *.5432                 *.*                    LISTEN     
tcp6       0      0  *.5432                 *.*                    LISTEN     
tcp4       0      0  127.0.0.1.62258        127.0.0.1.5432         TIME_WAIT  
8082c9a9cef34101 stream      0      0 8082c9a03229fbb1                0                0                0 /tmp/.s.PGSQL.5432
adamhuan:shell/ $ 

登录PostgreSQL:

在Apple MacOS上面安装完成EnterpriseDB,也就是PostgreSQL之后,默认的BASE目录是:/Library/PostgreSQL/14
具体如下:
adamhuan:14/ $ pwd                                                                                                                                                      [18:07:07]
/Library/PostgreSQL/14
adamhuan:14/ $                                                                                                                                                          [18:07:09]
adamhuan:14/ $ ls -ltr                                                                                                                                                  [18:07:09]
total 400
-rw-r--r--   1 root      daemon  61721 Nov  9 13:43 commandlinetools_3rd_party_licenses.txt
-rw-r--r--   1 root      daemon  70256 Nov  9 13:43 pgAdmin_3rd_party_licenses.txt
-rw-r--r--   1 root      daemon  47762 Nov  9 13:43 StackBuilder_3rd_party_licenses.txt
-rw-r--r--   1 root      daemon   1388 Nov  9 13:44 server_license.txt
-rw-r--r--   1 root      daemon   1026 Nov  9 13:44 pgAdmin_license.txt
drwxr-xr-x   4 root      daemon    128 Nov 23 19:50 share
drwxr-xr-x   3 root      daemon     96 Nov 23 19:50 pgAdmin 4.app
drwxr-xr-x   3 root      daemon     96 Nov 23 19:50 stackbuilder.app
drwxr-xr-x   6 root      daemon    192 Nov 23 19:50 debug_symbols
drwxr-xr-x   3 root      daemon     96 Nov 23 19:51 uninstall-postgresql.app
drwx------  11 postgres  daemon    352 Nov 24 19:47 Library
drwxr-xr-x   6 root      daemon    192 Dec 29 17:20 doc
drwxr-xr-x  37 root      daemon   1184 Dec 29 17:20 include
drwxr-xr-x   4 root      daemon    128 Dec 29 17:20 installer
drwxr-xr-x  37 root      daemon   1184 Dec 29 17:21 bin
drwxr-xr-x  55 root      daemon   1760 Dec 29 17:21 lib
-rwxr-xr-x   1 root      daemon    371 Dec 29 17:21 pg_env.sh
drwxr-xr-x  12 root      daemon    384 Dec 29 17:21 scripts
-rw-r--r--   1 root      daemon   1160 Dec 29 17:21 installation_summary.log
drwx------  28 postgres  daemon    896 Dec 29 17:21 data
adamhuan:14/ $     

要访问,要登录PostgreSQL:
adamhuan:14/ $ ./scripts/runpsql.sh                                                                                                                                     [18:09:14]
Server [localhost]: 
Database [postgres]: 
Port [5432]: 
Username [postgres]: 
Password for user postgres: 
psql (14.1)
Type "help" for help.

postgres=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 adamhuan  | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | 
 postgres  | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | 
 template0 | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 test      | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | 
(5 rows)

postgres=# \q
adamhuan:14/ $ 

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

隐藏
变装