http://www.cnblogs.com/huayumeng/p/3156263.html
postgresql使用文檔之一 初始化數據存儲區
17.2. 創建一個數據庫集群(Database Cluster)
在你能做任何事情之前,你必須在磁盤上初始化一塊存儲空間。我們稱這為一個數據庫集群(database cluster). 一個Database cluster是一批被一個運行着數據庫服務的示例所管理的數據庫.初始化以后,一個database cluster將會包含一個名為 postgres的數據庫,它是一個被一些工具、用戶和第三方應用使用的默認數據庫。數據庫服務器本身不需要 postgres ,但是很多外部的程序會假設它存在。另外一個在每一個cluster初始化時創建的數據庫叫做 template1. 就像它的名字所暗示,它會被用來作為一個創建后續數據庫所使用的模板;它不應該被實際工作所使用(參考21章獲取關於在一個集群中創建新的數據庫的信息)
在文件系統術語中,一個database cluster是單個的目錄,所有的數據會被存儲在這個目錄下。我們稱這個目錄為數據目錄(data directory)或數據區域(data area).選擇在哪個目錄下存儲您的數據完全取決於您,沒有默認目錄,盡管諸如/usr/local/pgsql/data或/var/lib/pgsql/data之類的目錄作為數據目錄是比較流行的。初始化一個database cluster,使用initdb命令,它是和PostgreSQL一起安裝的。您期望的的database cluster文件系統目錄使用選項 -D標注,如例:
$initdb -D /usr/local/pgsql/data
注意在您登錄PostgreSQL用戶賬戶之前必須先執行這個命令,這在上一節已經描述過了。(提示:您可以設置環境變量PGDATA來替換-D選項)
可供選擇的,您也可以通過pg_ctl程序像下面這樣運行 initdb
$pg_ctl -D /usr/local/pgsql/data initdb
如果您使用pg_ctl啟動和停止服務器(查看17.3節)將會更加直觀。這樣的話在管理數據庫服務器示例時pg_ctl將會是唯一的一個命令。
initdb將會嘗試創建你指定的一個不存在的目錄。很有可能您沒有權限創建(如果您尊隨我們的建議並創建了一個非特權賬戶)。在這種情況下,您應該創建這個目錄(比如用root權限),然后改變這個目錄的擁有者(owner)為PostgreSQL用戶。以下示范應該如何做:
root# mkdir /usr/local/pgsql/data root# chown postgres /usr/local/pgsql/data root# su postgres postgres$ initdb -D /usr/local/pgsql/data
如果數據目錄已經存在且初始化了的話,initdb將不會運行。
由於數據目錄包含了所有存儲在數據庫里的數據,因此應該有對未授權的訪問的安全機制。initdb收回了所有其他用戶的訪問權限,除了PostgreSQL用戶.
然而,盡管這個目錄下的內容是安全的,默認的客戶授權設置允許任何本地用戶連接數據庫甚至成為數據庫超級用戶(管理員)。如果您不信任本地的其他用戶,我們建議您使用任意一種initdb的選項-W,--pwprompt或--pwfile來分配給數據庫超級用戶的密碼。並且,指定-A md5或-A password,這樣默認的 trust 授權模式不起作用;或者在運行initdb后,第一次啟動您的數據庫服務器之前修改生成的pg_hda.conf文件。(其他的合理的途徑包括使用peer授權或文件系統權限來限制鏈接。查看19章獲取更多信息)
initdb同時為database cluster初始化默認的locale,一般而言,它只是使用本地locale設置並將其應用到初始化的數據庫中。為數據庫指定一個其他的locale是可能的;更多的信息可以在22.1節找到。默認的應用在特定的database cluster上的排序(sort order)是被initdb設置的,並且如果您創建了使用不同的排序的新的數據庫,除非您刪除重建它,在template數據庫中使用的order是不會改變的。使用其他的locale而不是使用C或POSIX會對性能產生影響。因此在第一次正確的選擇選項是很重要的。
initdb同時為database cluster設置默認的字符集和encoding。一般而言應該選擇匹配locale設置。更多細節查看22.3節
17.2.1 網絡文件系統
很多安裝在網絡文件系統創建database cluster。有些直接用NFS,或者使用內部使用NFS的NAS來完成。PostgreSQL並非特定於NFS文件系統,意味着它使用NFS的方式和本地連接的驅動(DAS,直接連接的存儲器)完全一致。如果客戶端和服務端的NFS實現未遵循標准的語意(semantics),這可能會產生可靠性問題(查看http://www.time-travellers.org/shane/papers/NFS_considered_harmful.html).具體而言,延時(異步)寫入NFS服務器會產生可靠性問題;如果可以,盡量同步掛載(不用緩存)
http://www.postgresql.org/docs/9.3/static/app-initdb.html
initdb
Description
initdb creates a new PostgreSQL database cluster. A database cluster is a collection of databases that are managed by a single server instance.
Creating a database cluster consists of creating the directories in which the database data will live, generating the shared catalog tables (tables that belong to the whole cluster rather than to any particular database), and creating the template1 and postgres databases. When you later create a new database, everything in the template1 database is copied. (Therefore, anything installed in template1 is automatically copied into each database created later.) The postgres database is a default database meant for use by users, utilities and third party applications.
Although initdb will attempt to create the specified data directory, it might not have permission if the parent directory of the desired data directory is root-owned. To initialize in such a setup, create an empty data directory as root, then use chown to assign ownership of that directory to the database user account, then su to become the database user to run initdb.
initdb must be run as the user that will own the server process, because the server needs to have access to the files and directories that initdb creates. Since the server cannot be run as root, you must not run initdb as root either. (It will in fact refuse to do so.)
initdb initializes the database cluster's default locale and character set encoding. The character set encoding, collation order (LC_COLLATE) and character set classes (LC_CTYPE, e.g. upper, lower, digit) can be set separately for a database when it is created. initdb determines those settings for the template1 database, which will serve as the default for all other databases.
To alter the default collation order or character set classes, use the --lc-collate and --lc-ctype options. Collation orders other than C or POSIX also have a performance penalty. For these reasons it is important to choose the right locale when running initdb.
The remaining locale categories can be changed later when the server is started. You can also use --locale to set the default for all locale categories, including collation order and character set classes. All server locale values (lc_*) can be displayed via SHOW ALL. More details can be found in Section 22.1.
To alter the default encoding, use the --encoding. More details can be found in Section 22.3.
Options
-
-A authmethod
--auth=authmethod -
This option specifies the authentication method for local users used in pg_hba.conf (host and local lines). Do not use trust unless you trust all local users on your system. trust is the default for ease of installation.
- --auth-host=authmethod
-
This option specifies the authentication method for local users via TCP/IP connections used in pg_hba.conf (host lines).
- --auth-local=authmethod
-
This option specifies the authentication method for local users via Unix-domain socket connections used in pg_hba.conf (local lines).
-
-D directory
--pgdata=directory -
This option specifies the directory where the database cluster should be stored. This is the only information required by initdb, but you can avoid writing it by setting the PGDATA environment variable, which can be convenient since the database server (postgres) can find the database directory later by the same variable.
-
-E encoding
--encoding=encoding -
Selects the encoding of the template database. This will also be the default encoding of any database you create later, unless you override it there. The default is derived from the locale, or SQL_ASCII if that does not work. The character sets supported by the PostgreSQL server are described in Section 22.3.1.
-
-k
--data-checksums -
Use checksums on data pages to help detect corruption by the I/O system that would otherwise be silent. Enabling checksums may incur a noticeable performance penalty. This option can only be set during initialization, and cannot be changed later. If set, checksums are calculated for all objects, in all databases.
- --locale=locale
-
Sets the default locale for the database cluster. If this option is not specified, the locale is inherited from the environment that initdb runs in. Locale support is described in Section 22.1.
-
--lc-collate=locale
--lc-ctype=locale
--lc-messages=locale
--lc-monetary=locale
--lc-numeric=locale
--lc-time=locale -
Like --locale, but only sets the locale in the specified category.
- --no-locale
-
Equivalent to --locale=C.
-
-N
--nosync -
By default, initdb will wait for all files to be written safely to disk. This option causes initdb to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing, but should not be used when creating a production installation.
- --pwfile=filename
-
Makes initdb read the database superuser's password from a file. The first line of the file is taken as the password.
-
-S
--sync-only -
Safely write all database files to disk and exit. This does not perform any of the normal initdb operations.
-
-T CFG
--text-search-config=CFG -
Sets the default text search configuration. See default_text_search_config for further information.
-
-U username
--username=username -
Selects the user name of the database superuser. This defaults to the name of the effective user running initdb. It is really not important what the superuser's name is, but one might choose to keep the customary name postgres, even if the operating system user's name is different.
-
-W
--pwprompt -
Makes initdb prompt for a password to give the database superuser. If you don't plan on using password authentication, this is not important. Otherwise you won't be able to use password authentication until you have a password set up.
-
-X directory
--xlogdir=directory -
This option specifies the directory where the transaction log should be stored.
Other, less commonly used, options are also available:
-
-d
--debug -
Print debugging output from the bootstrap backend and a few other messages of lesser interest for the general public. The bootstrap backend is the program initdb uses to create the catalog tables. This option generates a tremendous amount of extremely boring output.
- -L directory
-
Specifies where initdb should find its input files to initialize the database cluster. This is normally not necessary. You will be told if you need to specify their location explicitly.
-
-n
--noclean -
By default, when initdb determines that an error prevented it from completely creating the database cluster, it removes any files it might have created before discovering that it cannot finish the job. This option inhibits tidying-up and is thus useful for debugging.
Other options:
-
-V
--version -
Print the initdb version and exit.
-
-?
--help -
Show help about initdb command line arguments, and exit.
Environment
- PGDATA
-
Specifies the directory where the database cluster is to be stored; can be overridden using the -D option.
This utility, like most other PostgreSQL utilities, also uses the environment variables supported by libpq (see Section 31.14).
NAME
initdb - 創建一個新的 PostgreSQL數據庫集群
SYNOPSIS
initdb [ option... ] --pgdata | -D directory DESCRIPTION ����述 initdb 創建一個新的 PostgreSQL 數據庫集群。 一個數據庫集群是由單個服務器實例管理的數據庫集合。 創建數據庫系統包括創建數據庫數據的宿主目錄, 生成共享的系統表(不屬於任何特定數據庫的表)和創建 template1 數據庫。當你以后再創建一個新數據庫時, template1 數據庫里所有內容都會拷貝過來。 它包括填充了象內建類型這樣的系統表。 initdb 初始化該數據庫集群的缺省區域和字符集編碼。 有些區域范疇對該集群而言是全生命期固定的,因此在運行 initdb 的時候選取正確的是非常重要的。 其它區域范疇可以在服務器啟動之后的時間里改變。 initdb 將把那些區域設置寫到 postgresql.conf 配置文件,這樣它們就是缺省的, 但是我們可以通過編寄切┪募來修改它們。 要設置 initdb 使用的區域,參閱 --locale 選項的描述。字符集編碼可以在數據庫創建的時候獨立設置。 initdb 決定 template1 數據庫的編碼,而該編碼將成為所有其它數據庫的缺省。 要修改缺省編碼,我們可以使用 --encoding 選項。 initdb 必須以運行數據庫服務器進程的用戶身份運行它。 因為服務器需要能夠訪問 initdb 創建的文件和目錄。 因為服務器不能以 root 身份運行,所以你也不能以 root 身份運行 initdb。(實際上它拒絕以 root 身份運行。) 盡管initdb會嘗試創建相應的數據目錄, 但- 常會發生它沒有權限做這些事情的情況。因為所需要的目錄的父目錄通常是 root 所有的目錄。 要為此安排做一個設置,用 root 創建一個空數據目錄, 然后用 chown 把該目錄的所有權交給數據庫用戶帳號, 然后 su 成數據庫用戶,最后以數據庫用戶身份運行 initdb。 OPTIONS����項 -D directory --pgdata=directory 這個選項聲明數據庫集群應該存放在哪個目錄。 這是initdb需要的唯一信息,但是你可以通過設置 PGDATA 環境變量來避免鍵入, 這樣做可能方便一些,因為稍后數據庫服務器(postmaster)可以通過同一個變量找到數據庫目錄。 -E encoding --encoding=encoding 選擇模板數據庫的編碼方式。這將是你以后創建的數據庫的缺省編碼方式, 除非你創建數據庫時覆蓋了它。 缺省是 SQL_ASCII。 --locale=locale 為數據庫集群設置缺省的區域。如果沒有聲明這個選項,那么區域 是從 initdb 運行的環境中繼承過來的。 --lc-collate=locale --lc-ctype=locale --lc-messages=locale --lc-monetary=locale --lc-numeric=locale --lc-time=locale 類似 --locale,但是只設置特殊范疇的區域。 -U username --username=username 選擇數據庫超級用戶的用戶名。 缺省是運行 initdb 的用戶的有效用戶。 超級用戶的名字是什么並不重要, 但是我們可以選擇習慣的名字 postgres,即使操作系統的用戶名字不一樣也無所謂。 -W --pwprompt 令 initdb 提示輸入數據庫超級用戶的口令。 如果你不准備使用口令認證,這個東西並不重要。 否則你將不能使用口令認證直到你設置了口令。 其他不常用的參數還有: -d --debug 從初始化后端打印調試輸出以及一些其它的一些普通用戶不太感興趣的信息。 初始化后端是 initdb 用於創建系統表的程序。 這個選項生成大量非常煩人的輸出。 -L directory 告訴 initdb 到哪里找初始化數據庫所需要的輸入文件。 通常是不必要的。如果需要你明確聲明的話,程序會提示你輸入。 -n --noclean 缺省時,當initdb 發現一些錯誤妨八瓿紗唇ㄊ菘餳旱墓ぷ魘保 它將在檢測到不能結束工作之前將其創建的所有文件刪除。 這個選項禁止任何清理動作,因而對調試很有用。 ENVIRONMENT����境 PGDATA 聲明數據庫集群存儲的目錄;可以用 -D 選項覆蓋。
http://huangyandong.blog.51cto.com/1396940/742902
initdb
名稱:初始化一個PostgreSQL數據庫簇
語法:
initdb [OPTION] [DATADIR]
選項:
-A,--auth=METHOD:指定本地連接的認證方法
[-D,--pgdata=]DATADIR:指定數據庫簇的原始目錄(必須為空)
-E,--encoding=ENCODING:指定數據庫的默認編碼
--locale=LOCALE:設置數據庫的locale
--no-locale:等價--locale=C
--pwfile=FILE:從指定的文件FILE中讀取超級用戶的密碼
-T,--text-search-config=CFG:指定默認的配置
-U,--username=Username:指定用戶名
-W,--pwprompt:強制提示密碼輸入
-X,--xlogdir=XLOGDIR:指定事務日志的目錄文件
實例:
./initdb -D /usr/local/postgres/data
本文出自 “黃彥東” 博客,請務必保留此出處http://huangyandong.blog.51cto.com/1396940/742902
http://stackoverflow.com/questions/11814740/what-is-going-wrong-with-postgresql-initdb-why-is-the-utf-8-encoding-not-gett
I am using PostgreSQL 9.1. Trying to enforce UTF8 encoding as default. This is what I am doing.
Although the initilization process goes on without any problem, a
Why is the |
||
add a comment
|
Looks like you are calling initdb through a runlevel script of the OS. This script might not pass on the parameters. You better try executing initdb directly, you will need to perform the following steps starting as root and assuming the OS user account for the database is postgres.
|
||||
16.2. Creating a Database Cluster
Before you can do anything, you must initialize a database storage area on disk. We call this a database cluster. (SQL uses the term catalog cluster.) A database cluster is a collection of databases that is managed by a single instance of a running database server. After initialization, a database cluster will contain a database named postgres, which is meant as a default database for use by utilities, users and third party applications. The database server itself does not require the postgres database to exist, but many external utility programs assume it exists. Another database created within each cluster during initialization is called template1. As the name suggests, this will be used as a template for subsequently created databases; it should not be used for actual work. (See Chapter 20 for information about creating new databases within a cluster.)
Note: The following description applies only to Postgres-XC
You should initialize database cluster for each Coordinator and Datanode.
In file system terms, a database cluster will be a single directory under which all data will be stored. We call this the data directory or data area. It is completely up to you where you choose to store your data. There is no default, although locations such as /usr/local/pgsql/data or /var/lib/pgsql/data are popular. To initialize a database cluster, use the command initdb, which is installed with Postgres-XC. The desired file system location of your database cluster is indicated by the -D option, for example:
$ initdb -D /usr/local/pgsql/data --nodename foo
Note that you must execute this command while logged into the Postgres-XC user account, which is described in the previous section. You should assign separate data directory to each Coordinator and Datanode if you are configuring them in a same server.
Tip: As an alternative to the -D option, you can set the environment variable PGDATA.
If you configure multiple Coordinator and/or Datanode, you cannot share PGDATA among them and you must specify data directory explicitly.
--nodename is mandatory for all the nodes at initialization
Alternatively, you can run initdb via the pg_ctl program like so:
$ pg_ctl -D /usr/local/pgsql/data -o '--nodename foo' initdb
This may be more intuitive if you are using pg_ctl for starting and stopping the server (see Section 16.3), so that pg_ctl would be the sole command you use for managing the database server instance.
initdb will attempt to create the directory you specify if it does not already exist. It is likely that it will not have the permission to do so (if you followed our advice and created an unprivileged account). In that case you should create the directory yourself (as root) and change the owner to be the Postgres-XC user. Here is how this might be done:
root# mkdir /usr/local/pgsql/data root# chown postgres /usr/local/pgsql/data root# su postgres postgres$ initdb -D /usr/local/pgsql/data --nodename foo
initdb will refuse to run if the data directory looks like it has already been initialized.
Because the data directory contains all the data stored in the database, it is essential that it be secured from unauthorized access. initdb therefore revokes access permissions from everyone but the Postgres-XC user.
However, while the directory contents are secure, the default client authentication setup allows any local user to connect to the database and even become the database superuser. If you do not trust other local users, we recommend you use one of initdb's -W, --pwprompt or --pwfile options to assign a password to the database superuser. Also, specify -A md5 or -A passwordso that the default trust authentication mode is not used; or modify the generated pg_hba.conf file after running initdb, but before you start the server for the first time. (Other reasonable approaches include using peer authentication or file system permissions to restrict connections. See Chapter 18 for more information.)
initdb also initializes the default locale for the database cluster. Normally, it will just take the locale settings in the environment and apply them to the initialized database. It is possible to specify a different locale for the database; more information about that can be found in Section 21.1. The default sort order used within the particular database cluster is set by initdb, and while you can create new databases using different sort order, the order used in the template databases that initdb creates cannot be changed without dropping and recreating them. There is also a performance impact for using locales other than C or POSIX. Therefore, it is important to make this choice correctly the first time.
initdb also sets the default character set encoding for the database cluster. Normally this should be chosen to match the locale setting. For details see Section 21.3.
16.2.1. Network File Systems
Many installations create database clusters on network file systems. Sometimes this is done directly via NFS, or by using a Network Attached Storage (NAS) device that uses NFSinternally. Postgres-XC does nothing special for NFS file systems, meaning it assumes NFS behaves exactly like locally-connected drives (DAS, Direct Attached Storage). If client and server NFS implementations have non-standard semantics, this can cause reliability problems (see http://www.time-travellers.org/shane/papers/NFS_considered_harmful.html). Specifically, delayed (asynchronous) writes to the NFS server can cause reliability problems; if possible, mount NFS file systems synchronously (without caching) to avoid this. Also, soft-mounting NFS is not recommended. (Storage Area Networks (SAN) use a low-level communication protocol rather than NFS.)
http://www.ovirt.org/Installing_PostgreSQL_DB
Installing PostgreSQL DB
Contents[hide] |
Warning
This page contains obsolete information and has been recommended for deletion!
Installing
Please take into account that installing and starting a database is a system administration task, so all the commands suggested in this page are to be executed with the root
user.
Fedora
# yum install -y postgresql-server
Debian
# apt-get install postgresql
Make sure you are using PostgreSQL 8.4.8 or later. Check your version with:
# psql --version
Note: for earlier PostgreSQL versions, a patch is needed.
Running the service
From PostgreSQL 9
Before starting the database for the first time you need to initialize it using the postgresql-setup
command with the initdb
option:
Fedora
# postgresql-setup initdb
Once it is initialized you can start and stop it with the systemctl
command. For example, to start it:
# systemctl start postgresql.service
It is recommended to configure the service so that it is automatically started the next time the machine is rebooted:
# systemctl enable postgresql.service
If the database needs to be recreated from scratch the way to do it is to stop the service, remove the data directory, run the postgresql-setup
command again, and start the service:
# systemctl stop postgresql.service # rm -rf /var/lib/pgsql/data # postgresql-setup initdb # systemctl start postgresql.service
Debian
The database is automatically initialized, started and configured to start during boot as part of the installation of the package, no need to perform any additional initialization.
To start, stop or restart it use the /etc/init.d/postgresql
script:
# /etc/init.d/postgresql start
For PostgreSQL 8 or earlier (not recommended)
Before starting the database for the first time you need to initialize it running the initdb
command with the postgres
user:
# su - postgres -c 'initdb -U postgres -D /var/lib/pgsql/data/'
Once it is initialized you can start and stop it with the service
command. For example, to start it run the following command:
# service postgresql start
It is recommended to configure the service so that it is automatically started the next time the machine is rebooted:
# chkconfig postgresql on
Connecting to the database
Note that this instructions are mostly the same for all distributions, the main difference is the location of the configuration files. For reference see the PostgreSQL documentation here.
Fedora
Edit the /var/lib/pgsql/data/pg_hba.conf
file and set authentication parameters as follows:
local all all peer host all all 127.0.0.1/32 md5 host all all ::1/128 md5
After that run systemctl restart postgresql.service
so that the new settings will take effect.
Debian
Edit the /etc/postgresql/9.1/main/pg_hba.conf
file and set authentication parameters as follows:
local all all peer host all all 127.0.0.1/32 md5 host all all ::1/128 md5
After that run /etc/init.d/postgresql restart
so that the new settings will take effect.
Connecting from other hosts (optional)
If you want to be able to connect to PostgreSQL from other hosts (i.e. not from localhost only) you will need to change the listen_addresses
parameter, as the default is to accept local connections only.
Fedora
Edit the /var/lib/pgsql/data/postgresql.conf
file:
listen_addresses = '0.0.0.0'
And you will need also to allow access from external hosts in the /var/lib/pgsql/data/pg_hba.conf
file:
host all all 10.35.0.0/16 trust
The 10.35.0.0/16
network address and mask are just an example, make sure you replace it with what you want to give permissions to.
After all these changes restart the PostgreSQL service:
# systemctl restart postgresql.service
Debian
Same as in Fedora, but the location of the files are /etc/postgresql/9.1/main/postgresql.conf
and /etc/postgresql/9.1/main/pg_hba.conf
.
After all these changes restart the PostgreSQL service:
# /etc/init.d/postgresql restart
http://www.linuxfly.org/post/88/
項目需要部署Open Country,其要求使用Postgresql 7.0或8.0版本。系統為紅旗DC 5.0 for x86,默認安裝有Postgresql 8.0。
啟動時候出現下面的故障提示:
正在初始化數據庫: [失敗]
啟動 postgresql 服務: [失敗]
查看/etc/init.d/postgresql文件,嘗試手動初始化數據庫:
-bash-3.00$ initdb
屬於此數據庫系統的文件宿主為用戶 "postgres".
此用戶也必須為服務器進程的宿主.
數據庫簇將帶有 locale zh_CN.GB18030 初始化.
initdb: 無法為 locale "zh_CN.GB18030" 找到合適的編碼
帶 -E 選項重新運行 initdb.
請用 "initdb --help" 獲取更多的信息.
故障應該和系統的locale設定有關,使用下面的命令解決:
屬於此數據庫系統的文件宿主為用戶 "postgres".
此用戶也必須為服務器進程的宿主.
數據庫簇將帶有 locale C 初始化.
修復已存在目錄 /var/lib/pgsql/data 的權限 ... 成功
創建目錄 /var/lib/pgsql/data/global ... 成功
創建目錄 /var/lib/pgsql/data/pg_xlog ... 成功
創建目錄 /var/lib/pgsql/data/pg_xlog/archive_status ... 成功
創建目錄 /var/lib/pgsql/data/pg_clog ... 成功
創建目錄 /var/lib/pgsql/data/pg_subtrans ... 成功
創建目錄 /var/lib/pgsql/data/base ... 成功
創建目錄 /var/lib/pgsql/data/base/1 ... 成功
創建目錄 /var/lib/pgsql/data/pg_tblspc ... 成功
選擇默認最大聯接數 (max_connections) ... 100
選擇默認共享緩沖區大小 (shared_buffers) ... 1000
創建配置文件 ... 成功
在 /var/lib/pgsql/data/base/1 中創建 template1 數據庫 ... 成功
初始化 pg_shadow ... 成功
啟動不限制系統表行大小 ... 成功
初始化 pg_depend ... 成功
創建系統視圖 ... 成功
加載 pg_description ... 成功
創建字符集轉換 ... 成功
對內建對象設置權限 ... 成功
創建信息模式 ... 成功
清理數據庫 template1 ... 成功
拷貝 template1 到 template0 ... 成功
警告: 為本地連接啟動了 "trust" 認證.
你可以通過編輯 pg_hba.conf 更改或你下
次運行 initdb 時使用 -A 選項.
成功. 您現在可以用下面的命令運行數據庫服務器:
postmaster -D /var/lib/pgsql/data
或者
pg_ctl -D /var/lib/pgsql/data -l logfile start
退出到root用戶,重新運行服務:
啟動 postgresql 服務: [ 確定 ]
一切正常。問題解決!
initdb
directly as a superuser. gave aninitdb: cannot be run as root Please log in (using, e.g., "su") as the (unprivileged) user that will own the server process.
error. After logging in as an unprivileged user I was able to initialize the db with the proper encoding. – ThinkingMonkey Aug 5 '12 at 8:38