postgresql基礎配置

2021-08-07 10:58:31 字數 1841 閱讀 4986

原文

1安裝postgresql:

yum install postgresql-server

2建立資料庫

createdb mydb

如果出現以下錯誤:createdb: 無法聯接到資料庫 postgres: 無法聯接到伺服器: 沒有那個檔案或目錄伺服器是否在本地執行並且在 unix 域套接字」/tmp/.s.pgsql.5432」上準備接受聯接? 表明伺服器還沒有啟動。

由此,我們需要啟動伺服器,由於是第一次,我們需要設定一些一本資訊:

su postgres

initdb -d /usr/local/pgsql/data

會出現如下的資訊:

屬於此資料庫系統的檔案宿主為使用者 「postgres」.

此使用者也必須為伺服器程序的宿主.

資料庫簇將帶有 locale zh_cn.utf-8 初始化.

預設的資料庫編碼已經相應的設定為 utf8.

initdb: 無法為語言環境」zh_cn.utf-8」 找到合適的文字搜尋配置

預設的文字搜尋配置將會被設定到」******」

建立目錄 /usr/local/pgsql/data … 成功

正在建立子目錄 … 成功

選擇預設最大聯接數 (max_connections) … 100

選擇預設共享緩衝區大小 (shared_buffers) … 32mb

建立配置檔案 … 成功

在 /usr/local/pgsql/data/base/1 中建立 template1 資料庫 … 成功

初始化 pg_authid … 成功

初始化dependencies … 成功

建立系統檢視 … 成功

正在載入系統物件描述 … 成功

建立字符集轉換 … 成功

正在建立字典 … 成功

對內建物件設定許可權 … 成功

建立資訊模式 … 成功

清理資料庫 template1 … 成功

拷貝 template1 到 template0 … 成功

拷貝 template1 到 template0 … 成功

警告: 為本地連線啟動了 「trust」 認證.

你可以通過編輯 pg_hba.conf 更改或你下

次執行 initdb 時使用 -a 選項.

成功. 您現在可以用下面的命令執行資料庫伺服器:

postmaster -d /usr/local/pgsql/data

或者pg_ctl -d /usr/local/pgsql/data -l logfile start

啟動伺服器

postgres -d /usr/local/pgsql/data

或者用chkconfig postgres on

service postgres start這樣開機啟動資料庫伺服器

然後及時使用psql 進行資料庫的登入使用。

擴充套件閱讀

linux下postgresql基礎操作

postgresql vs. ms sql server

postgresql資源整理

在 ubuntu 上安裝世界上最先進的開源資料庫 postgresql 9.4 和 phppgadmin

免費程式設計書籍集合

為您推薦

linux postgresql 基礎配置指南

cacti監控

sphinx教程2__安裝、配置和使用

postgresql資料庫備份與恢復技術比較

hearbeat+pacemaker的方式實現postgresql流複製自動切換

更多 postgresql

postgresql 日誌配置

log destination csvlog csv模式輸出 logging collector on 收集日誌開啟 log directory pg log 輸出日期的陌路 log filename postgresql u.log 輸出的檔名加星期格式 log truncate on rotat...

PostgreSQL配置優化

作業系統 ubuntu13.04 系統位數 64cpu intel r core tm 2 duo cpu 記憶體4g 硬碟seagate st2000dm001 1ch164 測試工具 postgresql 9.1.11 工具名稱 pgbench 資料量200w 整個資料庫大小約為300m 模擬客...

PostgreSQL配置優化

url 測試工具 工具名稱 pgbench 資料量 200w 整個資料庫大小約為300m 模擬客戶端數 4 執行緒數 4 測試時間 60秒 準備命令 pgbench i s 20 pgbenchdb 測試命令 pgbench r j4 c4 t60 testdb 配置檔案 預設的配置配置檔案是儲存在...