FREEBSD安裝POSTGRESQL筆記,freebsdpostgresql

來源:互聯網
上載者:User

FREEBSD安裝POSTGRESQL筆記,freebsdpostgresql

折騰了好長時間,重新初始化好多次。

安裝的時候,命令:pkg search postgresql.額 好多包,選擇最新的9.4安裝server,會一起安裝client。安裝完會有很多文字提示,這個很有用。安裝完會建立一個使用者pgsql,家目錄為/usr/local/pgsql.

第一步

要先切換到pgsql使用者下,su root, su pgsql。然後在pgsql home目錄建立data檔案夾。root使用者下好像是不允許的
初始化,initdb -D /usr/local/pgsql/data/ ,會產生很多檔案。初始化資料庫儲存區,會自動建立一個 postgres的資料庫,放亂七八糟的設定和第三方外掛程式的資料。還會有一個模板 template1。這裡還不是很清楚,以後建立資料庫就會用這個模板建立。這裡要說的是資料庫編碼的問題,這裡悲劇的初始化了好多次。
預設執行上邊的命令後,提示文字會跟你說(當時沒看。。)預設資料庫編碼為“sql_ascii”,預設文本搜尋設定為 english。。我靠執行的時候就瞅著螢幕發獃了,就等執行完。。。重新初始化的方法,我也是從提示中看到的,直接initdb會提示你 要清空原來檔案夾或者建立。直接rm -rf *.initdb –help
可以看到字元編碼的設定用–encoding ,initdb –encoding=UTF8 -D /usr/local/pgsql/data/

啟動postgresql,啟動指令碼/usr/local/etc/rc.d/postgresql。開始要添加到/etc/rc.conf檔案,這個也是有提示的。
status not running,start成功

建立資料庫,createdb –encoding=UTF-8 bt,使用用戶端串連,qsql bt,
進去後 show server_encoding;查看server編碼,utf8
\encoding 查看用戶端編碼。用戶端還是SQL_ASCII,可以使用/encoding utf8改變用戶端編碼。
也可以直接使用\l查看。

ok了 基本沒別的問題了。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.