[root@localhost ~]# useradd postgres -m /home/postgres
If you don't have the home dir yet, you can add it at a later stage. You just need to stop all processes used by it first.
[root@localhost ~]# mkdir -p /home/postgres
[root@localhost ~]# chown postgres:postgres /home/postgres
[root@localhost ~]# usermod -d /home/postgres postgres
[root@localhost ~]# chown postgres:postgres /home/postgres
[root@localhost ~]# usermod -d /home/postgres postgres
Then, connect as postgres and start the server:
-bash-4.3$ initdb -D /var/lib/pgsql/data/
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 "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /var/lib/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
creating configuration files ... ok
creating template1 database in /var/lib/pgsql/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
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
copying template1 to template0 ... ok
copying 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 /var/lib/pgsql/data/
or
pg_ctl -D /var/lib/pgsql/data/ -l logfile start
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 "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /var/lib/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
creating configuration files ... ok
creating template1 database in /var/lib/pgsql/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
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
copying template1 to template0 ... ok
copying 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 /var/lib/pgsql/data/
or
pg_ctl -D /var/lib/pgsql/data/ -l logfile start
Start the server:
-bash-4.3$ pg_ctl -D /var/lib/pgsql/data/ -l logfile start
You can now create a database and connect to it:
-bash-4.3$ createdb test1
-bash-4.3$ psql test1
psql (9.3.6)
Type "help" for help.
test1=#
-bash-4.3$ psql test1
psql (9.3.6)
Type "help" for help.
test1=#
To stop the server:
$ pg_ctl stop
No comments:
Post a Comment