軟件—postgresql安裝

2018.6.4更新
通過homebrew安裝Graphviz

vandeMacBook-Air:~ enniu$ ruby -version
vandeMacBook-Air:~ enniu$ brew install ruby@2.3
vandeMacBook-Air:~ enniu$ brew install Graphviz
vandeMacBook-Air:~ enniu$ brew list

homebrew方法

1、Homebrew官網(wǎng)
2、原理

通過 Homebrew 或者 Homebrew Cask 安裝的軟件都會集中在一個目錄下面,再由 Homebrew 將相關(guān)軟件軟鏈接到相關(guān)路徑。舉個例子,如果當(dāng)我們訪問系統(tǒng)中的 A 文件時,系統(tǒng)都會將訪問路徑導(dǎo)向 B 文件對應(yīng)的路徑,那么 A 文件就是 B 文件的軟鏈接,這也是 Homebrew 的原理。
參考:借助 Homebrew Cask,教你快速下載安裝 Mac App 新姿勢

3、安裝步驟
3.1 安裝Xcode
xcode-select --install     #完成 Xcode command line tools 安裝

3.2 安裝 Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
3.3 下載軟件
brew  install 軟件名
其他命令
brew list
4、啟用postgresql
initdb /usr/local/var/postgres    
#初始配置 PostgreSQL。若報錯,參考如下[Reinstalling PostgresSQL on Mac](http://www.tgreenidge.com/blog/installing-postgres)
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
# 啟動PostgreSql。因為未設(shè)置自動啟動,故每次都需要手動開啟
$ createdb test -O enniu -E UTF-8 -e   #用戶名為enniu,密碼默認(rèn)為postgres
$ psql -U enniu -d test 127.0.0.1  #連接數(shù)據(jù)庫。在終端窗口使用此命令調(diào)出postgresql
CREATE TABLE test (id int, text VARCHAR(50))    #建表
\d     #顯示數(shù)據(jù)表

官網(wǎng)下載方式

簡單介紹:Mac 上安裝和使用PostgreSQL的方法

psql: 是PostgreSQL數(shù)據(jù)庫的命令行交互工具
pgAdmin: 是PostgreSQL數(shù)據(jù)庫的圖形化管理工具


Postgres.app includes many command line tools. If you want to use them, you must configure the $PATH variable.
If you are using bash (default shell on OS X), add the following line to ~/.bash_profile:

export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.5/bin

參考:
postgreSQL增加環(huán)境變量
轉(zhuǎn)載:(Mac)在bash和zsh配置環(huán)境變量path的幾種方法

查看psql的絕對路徑

$ which psql     #結(jié)果為:/usr/local/bin/psql
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容