mac下使用postgresql

一. 使用home brew安装和管理:

安装篇:

1.brew info postgres : 可以查看可以安装到的最新版本的 postgresql

2.brew search postgres: 可以搜索到所有版本的postgresql, 目前自己用[email protected]这个版本

3.brew install [email protected]: 安装[email protected]

4.通过brew install安装完毕之后,[email protected]会自动随系统以服务的形式启动,默认用户名为postgres,没有密码。

管理篇:

1.如果你通过brew install postgres安装到最新版本的postgresql的话,brew会自动创建到/usr/local的链接,这样你可以直接在命令行里面使用bin目录下面的所有命令。但是如果你是按照上面的步骤安装的老版本的话,brew不会为你创建链接,那么你需要在terminal中执行 echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile 这行命令,将[email protected]的bin目录添加到系统环境变量中

2. brew services stop [email protected]: 停止服务

3. brew services start [email protected]: 启动服务

4. brew services restart [email protected]: 重启服务

5. pg_ctl [email protected] -D /usr/local/var/[email protected] start: 以程序的形式启动pg,关闭黑框后,程序即停止

6.pg_ctl [email protected] -D /usr/local/var/[email protected] stop: 终止 pg程序

7.pg_ctl [email protected] -D /usr/local/var/[email protected] restart: 重启

 使用篇:

1. 可以直接在命令行中间启动plsql来操作数据库

2. 下载pgadmin,目前有pgadminIII 和 pgadmin4两个版本可以使用。值得一提的是pgadmin4为bs结构的客户端软件。

卸载:

1.brew uninstall [email protected]: 这样即可卸载pg,如果将数据合并到新版本的pg,可以采用升级的方式,见其他文档

2.brew clean [email protected]: 清空pg的数据文件夹

二、图形化安装

1.直接使用bigsql打包好的pg全家桶,下载链接为:https://www.bigsql.org/postgresql/installers.jsp,这是一个图形化的安装界面,全傻瓜操作,安装程序会自动给你的系统添加一个postgresql用户。这个比较简单。

2.安装完成后,文件夹中会有卸载执行程序,双击执行即可。然后删除数据文件目录。然后删除postgresql用户。即可

你可能感兴趣的:(postgresql)