免安裝PostgreSQL啟動服務及建立資料庫

來源:互聯網
上載者:User

標籤:超級使用者   pac   network   code   通過   https   target   本地   res   

安裝環境windows7 64位系統

免安裝版本postgresql-10.3-1-windows-x64-binaries

=======================================

解壓之後無法串連資料庫,pgadmin4無法啟動,網上找各種方法,終於有一種可以啟動,又無法建立伺服器和資料庫,試了好多方法終於成功了,記錄下來:

 

1.首先到http://www.enterprisedb.com/products/pgbindownload.do下載postgreSQL程式,我下載的是win x64version 10.3-1;

 

2.下載之後將壓縮包裡的pgsql檔案夾解壓出來,為了方便,我直接放到E:\pgsql,不用安裝,但是需要設定一下環境變數……

 

3.自己製作一個簡單的批次檔,我這裡叫postgresql-10.3x64-1_install.bat,可以隨意命名:

set PGHOME=e:\pgsql
set PATH=%PGHOME%\bin;%path%
set PGHOST=localhost
set PGLIB=%PGHOME%\lib
set PGDATA=%PGHOME%\data

將這個批次檔複製到E:\pgsql

 

4.開啟cmd,切換到你的pgsql目錄,我是E:\pgsql,運行postgresql-10.3x64-1_install.bat

C:\Users\Administrator>E:
E:\>cd E:\pgsql
E:\pgsql>inst
E:\pgsql>set PGHOME=E:\pgsql
E:\pgsql>set PATH=E:\pgsql\bin;E:\Python26\Scripts;E:\Python26\;C:\Windows\syste
m32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1
.0\;C:\Program Files\Common Files\ThunderNetwork\KanKan\Codecs;C:\Users\Adminis
trator\AppData\Roaming\Python\Scripts;E:\Program Files\Google\google_appengine\
E:\pgsql>set PGHOST=localhost
E:\pgsql>set PGLIB=e:\pgsql\lib
E:\pgsql>set PGDATA=e:\pgsql\data

 

5.初始化資料庫

E:\pgsql>initdb --locale=C
屬於此資料庫系統的檔案宿主為使用者"Administrator".
此使用者也必須為伺服器處理序的宿主.
資料庫簇將帶有 locale C初始化.
預設的資料庫編碼已經相應的設定為 SQL_ASCII.
預設的文本搜尋配置將會被設定到"english"
建立目錄 e:/pgsql/data ...成功
正在建立子目錄 ...成功
選擇預設最大聯結數 (max_connections) ... 100
選擇預設共用緩衝區大小 (shared_buffers) ... 32MB
建立設定檔 ... 成功
在 e:/pgsql/data/base/1中建立 template1資料庫 ...成功
初始化 pg_authid ...成功
初始化dependencies ...成功
建立系統檢視表 ... 成功
正在載入系統對象描述 ...成功
建立字元集轉換 ...成功
正在建立字典 ... 成功
對內建對象設定許可權 ...成功

建立提示模式 ... 成功
loading PL/pgSQL server-side language ... 成功
清理資料庫 template1 ...成功
拷貝 template1到 template0 ...成功
拷貝 template1到 template0 ...成功
警告: 為本地串連啟動了"trust" 認證.
你可以通過編輯 pg_hba.conf更改或你下
次運行 initdb 時使用 -A 選項.
成功. 您現在可以用下面的命令運行資料庫伺服器:
""postmaster -D "e:/pgsql/data"
或者
""pg_ctl -D "e:/pgsql/data" -l E:\pgsql\pgdata.log start


6.啟動

E:\pgsql>pg_ctl start
正在啟動伺服器處理序
E:\pgsql>LOG: database system was shut down at 2010-12-13 13:41:20 HKT
LOG: autovacuum launcher started
LOG: database system is ready to accept connections

 

7.建立資料庫

E:\pgsql>E:\pgsql\bin\createdb -h127.0.0.1 mydb

建立使用者

E:\pgsql>E:\pgsql\bin\createuser -h 127.0.0.1 username
新的角色是否是超級使用者? (y/n) y
E:\pgsql>

 

8.開啟圖形操作介面管理資料庫E:\pgsql\bin\pgAdmin4.exe

pgAdmin 4/venv/Lib/site-packages/backports/__init__.py在此目錄下建立一個0位元組的空檔案__init__.py,然後pgAdmin4就能正常工作了。我不知道為什麼。網上找到的方法。


name:任意

Hostname/address:127.0.0.1

Username:任意

Password:自己好記的,含大小寫字母數字特殊字元,長度合適

關機重新啟動需要重啟一下服務,pgadmin4才能開啟。不然會報錯。

win+r 運行cmd,輸入一下命令

E:\pgsql\bin\pg_ctl -D "e:/pgsql/data" -l E:\pgsql\pgdata.log start

也可以將上面這句命令儲存為postgresql service start.bat

 

9. 使用DBeaver 5.0也可以開啟

 

免安裝PostgreSQL啟動服務及建立資料庫

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.