postgresql資料庫改變data目錄

2021-06-27 05:50:10 字數 996 閱讀 2879

原來的預設資料目錄/

var/

lib/

postgresql

/9.3

/data

/空間不夠大,改變資料目錄

1. 修改配置檔案/etc/postgresql/9.3/main/postgresql.conf

data_directory = '/home/pgdata'

2.  修改data_directory的所有者

chown -r postgres:postgres /home/pgdata

3.  這時候啟動會報error

* the postgresql server failed to start. please check the log output:

2014-11-25 09:55:02 cst fatal:  data directory "/home/pgdata" has group or world access

2014-11-25 09:55:02 cst detail:  permissions should be u=rwx (0700).

根據提示修改資料目錄許可權

chmod 700 /home/pgdata

4. 啟動依然會報錯

* the postgresql server failed to start. please check the log output:

2014-11-25 09:56:17 cst fatal:  "/home/pgdata" is not a valid data directory

2014-11-25 09:56:17 cst detail:  file "/home/pgdata/pg_version" is missing.

把預設資料目錄的東西拷貝過來

cp -r /var/lib/postgresql/9.3/main/* /home/pgdata/

5. 啟動 service postgresql start

postgresql模板資料庫

template0和template1為postgresql資料庫的模板資料庫,新建的資料庫預設使用template1作為模板。template0和template1的區別在於template0無法修改,因此你可以修改template1資料庫以定製新建立的資料庫。template資料庫無法被刪除 d...

postgresql資料庫安裝

安裝並初始化 1 解壓資料庫並放到指定目錄 在opt目錄下 tar xvzf postgresql 10.1 1 linux x64 binaries.tar.gz 解壓出來之後目錄為pgsql 2 mv pgsql usr local pgsql 3 建立pgsql使用者並設定密碼 useradd...

資料庫 postgresql 安裝

當前專案是使用django框架搭建介面層的業務,資料庫端使用了postgresql,這裡只是簡單記錄下自己的安裝流程,因為開發機器使用的mac,所以流程只是針對mac。這裡我使用的homebrew,這個工具就不多說了,沒有用過的可以到這裡 執行下面命令即可 brew install postgres...