當前位置:首頁 » 操作系統 » postgresql初始資料庫

postgresql初始資料庫

發布時間: 2023-05-23 21:12:26

① postgresql怎麼創建資料庫

1、使用CREATE DATABASE 該命令將創建一個資料庫PostgreSQL的shell提示符,但你應該有適當的許可權來創建資料庫。默認情況下,創建新的資料庫將通過克隆標准系統資料庫template1。 語法: CREATE DATABASE語句的基本語法如下: CREATE DATABASE db...

② postgresql是什麼資料庫

postgresql是功能強大的開源資料庫。

postgresql資料庫是功能強大的開源資料庫,它支持豐富的數據類型(如JSON和JSONB類型、數組類型)和自定義類型。

PostgreSQL資料庫提供了豐富的介面,可以很方便地擴展它的功能,如可以在GiST框架下實現自己的索引類型,支持使用C語言寫自定義函數、觸發器,也支持使用流行的編程語言寫自定義函數。

PostgreSQL資料庫優點

1、對超許可數量軟體使用的天然免疫力

對一些商業性質的資料庫銷售商來說,超許可數量的軟體使用是第一位的問題。而使用PostgreSQL,因為沒有任何授權的費用是,也就沒有任何人可以起訴您違反授權協議違規使用軟體。

2、比商業服務商更好的支持

除了有一般商業公司的支持外,我們還有由PostgreSQL專業人員和熱心的愛好者組成的各種社區,用戶可以向他們尋求支持和幫助。

3、員工成本的顯著降低

相對於市場上大型的商業私有資料庫軟體,我們的系統在設計和開發時已考慮僅需少量的維護和優化,同時仍保持所有功能正常、穩定和性能正常。不僅如此,我們的培訓過程相對於那些商業私有資料庫供應商來說,總體來說有更好的性價比、更容易管理和更接近真實的使用場景。

4、享有盛名的可靠性和穩定性

與很多商業私有資料庫不一樣的是,對很多公司特別常見的是,PostgreSQL在幾年的運行過程中幾乎未出現哪怕是一次的宕機情況,即使是一次,它就是這樣穩定地工作著。

5、擴展性

所有PostgreSQL的源代碼對所有人都是可以免費獲得的。如果您的公司員工需要定製或是給PostgreSQL增加一些功能,他們只需做很少的改動工作,也沒有額外的成本。全球PostgreSQL社區的專業人員和熱心的愛好者也在積極地擴展PostgreSQL的功能。

③ 如何訪問GitLab默認安裝的PostgreSQL資料庫

將GitLab的資料庫導入阿里雲PostgreSQL RDS
GitLab的資料庫用的是PostgreSQL,之前由於阿里雲RDS不支持PostgreSQL,只能將GitLab的資料庫部署在雲伺服器上。
6月1日得知阿里雲推出了PostgreSQL RDS,於是立馬將GitLab的資料庫遷移至PostgreSQL RDS。
下面分享一下遷移的主要操作步驟:

1)在GitLab伺服器上備份GitLab資料庫
操作命令:
sudo gitlab-rake gitlab:backup:create SKIP=db

註:這個命令原本是只備份資料庫,但實際運行時也會備份repositories,可以在完成資料庫備份時,ctrl+C直接退出。
資料庫備份成功後,會在 /var/opt/gitlab/backups/db 文件夾中看到 database.sql 文件,導入時只需將這個文件導入到阿里雲RDS。
2)在阿里雲RDS中創建GitLab的資料庫帳戶與資料庫
在阿里雲RDS控制台首頁點擊逗登錄資料庫地,進入idb.rds.aliyun.com,選擇對應的PostgreSQL實例。
a)創建2個帳戶:gitlab, gitlab-psql
b)創建gitlabhq_proction資料庫,所有者為gitlab。
3) 在GitLab伺服器上進行導入操作
a) cd /var/opt/gitlab/backups/db
b) psql -h [RDS實例網址] p 3433 -d gitlabhq_proction -U gitlab -f database.sql

④ 怎麼創建postgresql資料庫

1.在資料庫伺服器安裝完成後,默認有三個資料庫,可以通過下面兩種方法查看。
[html] view plain print?
postgres=# SELECT * FROM pg_database;
datname | datdba | encoding | datcollate | datctype | datistemplate | datallowconn | datconnlimit | datlastsysoid | datfrozenxid | dattablespace | datc
onfig | datacl
-----------+--------+----------+-------------+-------------+---------------+--------------+--------------+---------------+--------------+---------------+-----
------+-------------------------------------
template1 | 10 | 6 | zh_CN.UTF-8 | zh_CN.UTF-8 | t | t | -1 | 11563 | 648 | 1663 |
| {=c/postgres,postgres=CTc/postgres}
template0 | 10 | 6 | zh_CN.UTF-8 | zh_CN.UT

⑤ 如何在windows下手動初始化PostgreSQL資料庫

PostgreSQL資料庫手動初始化步驟:
1、創建用戶postgres,密碼同樣是postgres:
net user postgres postgres /add
2、在資料庫根目錄下建立data目錄:
C:\Program Files\PostgreSQL\9.3>md data

3、去掉administrator對data目錄的許可權:
C:\Program Files\攔攔PostgreSQL\前衡皮9.3>cacls data /e /t /r administrator

處理的目錄: C:\Program Files\PostgreSQL\9.3\data
4、將data目錄的許可權賦給postgres用戶:

C:\Program Files\PostgreSQL\9.3>cacls data /e /t /g postgres:C

處理的目錄: C:\Program Files\PostgreSQL\9.3\data
5、用postgres用戶打開cmd

C:\Program Files\PostgreSQL\9.3>runas /user:postgres cmd.exe

輸入 postgres 的密碼慧差:
試圖將 cmd.exe 作為用戶 "SURE-PC\postgres" 啟動...
6、進行初始化,初始化用戶為postgres,字元集為utf8,locale為C:
C:\Program Files\PostgreSQL\9.3\bin>initdb.exe -D ../data -E utf8 --locale C -U

postgres
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "C".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory ../data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
creating configuration files ... ok
creating template1 database in ../data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... not supported on this platform
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
ing template1 to template0 ... ok
ing template1 to postgres ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

"postgres" -D "../data"
or
"pg_ctl" -D "../data" -l logfile start
C:\Program Files\PostgreSQL\9.3\bin>

7、啟動資料庫,進入客戶端:
C:\Program Files\PostgreSQL\9.3\bin>"pg_ctl" -D "../data" start

server starting

C:\Program Files\PostgreSQL\9.3\bin>LOG: database system was shut down at 2014-
09-18 10:19:54 HKT
LOG: autovacuum launcher started
C:\Program Files\PostgreSQL\9.3\bin>LOG: database system is ready to accept con
nections
C:\Program Files\PostgreSQL\9.3\bin>psql.exe
psql (9.3.5)
Type "help" for help.
postgres=#
8、初始化完成。

⑥ postgresql 創建資料庫問題

1、使用CREATE DATABASE

該命令將創建一個資料庫PostgreSQL的shell提示符,但你應該有適當的許可權來創建資料庫。默認情況下,創建新的資料庫將通過克隆標准系統資料庫template1。

語法:

CREATE DATABASE語句的基本語法如下:

CREATEDATABASEdbname;

其中dbname是要創建的資料庫的名稱。

例子:

下面是一個簡單的例子,這將創建testdb在PostgreSQL模式:

postgres=# CREATE DATABASE testdb;
postgres-#


2、使用createdb的命令

PostgreSQL命令行可執行createdb是是SQL命令CREATE DATABASE一個包裝器。此命令和SQL命令CREATE DATABASE之間唯一的區別是,前者可以直接在命令行中運行,它允許的注釋被添加到資料庫中,全部在一個命令。

語法:

createdb語法如下所示:

createdb [option...] [dbname [description]]

參數

下表列出了參數及它們的描述。

參數名稱 描述

dbname The name of a database to create.

description Specifies a comment to be associated with the newly created database.

options command-line arguments which createdb accepts.

選項

下表列出了命令行參數CREATEDB接收:

選項 描述

-D tablespace Specifies the default tablespace for the database.

-e Echo the commands that createdb generates and sends to the server.

-E encoding Specifies the character encoding scheme to be used in this database.

-l locale Specifies the locale to be used in this database.

-T template Specifies the template database from which to build this database.

--help Show help about dropdb command line arguments, and exit.

-h host Specifies the host name of the machine on which the server is running.

-p port Specifies the TCP port or the local Unix domain socket file extension on which the server is listening for connections.

-U username User name to connect as.

-w Never issue a password prompt.

-W Force createdb to prompt for a password before connecting to a database.

打開命令提示符,然後去是PostgreSQL安裝所在的目錄。進入到bin目錄,執行下面的命令創建一個資料庫。

createdb -h localhost -p 5432 -U postgress testdb
password ******

上面的命令會提示Postgres的默認的PostgreSQL管理用戶的密碼,以便提供密碼和繼續創建新的資料庫。

一旦創建資料庫時可以使用上述方法,可以檢查它在列表中的資料庫使用l即反斜線el命令如下:

postgres-# l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+---------+-------+-----------------------
postgres | postgres | UTF8 | C | C |
template0 | postgres | UTF8 | C | C | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | C | C | =c/postgres +
| | | | | postgres=CTc/postgres
testdb | postgres | UTF8 | C | C |
(4 rows)

postgres-#

熱點內容
密碼加密php 發布:2025-04-22 16:07:09 瀏覽:582
imac存儲空間為什麼這么小 發布:2025-04-22 15:45:30 瀏覽:223
上傳時速是0 發布:2025-04-22 15:37:49 瀏覽:568
0基礎的編程 發布:2025-04-22 15:37:09 瀏覽:205
vnc怎麼查伺服器ip 發布:2025-04-22 15:29:20 瀏覽:158
百度雲ftp伺服器 發布:2025-04-22 15:17:50 瀏覽:656
平板哪個配置最高 發布:2025-04-22 15:16:20 瀏覽:830
天工編程 發布:2025-04-22 15:08:36 瀏覽:381
java感想 發布:2025-04-22 15:02:57 瀏覽:895
破解互聯網密碼多少錢 發布:2025-04-22 14:49:32 瀏覽:747