接下来我们打开一个命令窗口,进入到 PostgreSQL 的安装目录,并进入到 bin 目录,createdb 命令位于 PostgreSQL安装目录/bin 下,执行创建数据库的命令:

$ cd /Library/PostgreSQL/11/bin/$ createdb -h localhost -p 5432 -U postgres runoobdb
password ******

以上命令我们使用了超级用户 postgres 登录到主机地址为 localhost,端口号为 5432 的 PostgreSQL 数据库中并创建 runoobdb 数据库。

pgAdmin 工具创建数据库

pgAdmin 工具提供了完整操作数据库的功能: