Postgresql database initialization and Start in Debian Linux
===================Solved=======================
Error:
createdb: could not connect to database postgres: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
================================================1
* Find the location of "initdb" binary and run it with -D option and directory "data" where we want to install datas of postgres database.For that run the following command.
root@localhost:~# su postgres -c "/usr/lib/postgresql/8.3/bin/initdb -D /usr/lib/postgresql/8.3/data"
could not change directory to "/home/root"
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".
creating directory /usr/lib/postgresql/8.3/data ... initdb: could not create directory "/usr/lib/postgresql/8.3/data": Permission denied
================================================2
* change the permission of "/usr/lib/postgresql/"
if we could not create directory "/usr/lib/postgresql/8.3/data"
root@localhost:~# chmod -R 777 /usr/lib/postgresql/
================================================3
* Running the above command again.
root@localhost:~# su postgres -c "/usr/lib/postgresql/8.3/bin/initdb -D /usr/lib/postgresql/8.3/data"
could not change directory to "/home/root"
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".
creating directory /usr/lib/postgresql/8.3/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers/max_fsm_pages ... 24MB/153600
creating configuration files ... ok
creating template1 database in /usr/lib/postgresql/8.3/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.
Success. You can now start the database server using:
/usr/lib/postgresql/8.3/bin/postgres -D /usr/lib/postgresql/8.3/data
or
/usr/lib/postgresql/8.3/bin/pg_ctl -D /usr/lib/postgresql/8.3/data -l logfile start
root@localhost:~#
================================================4
* start the database server.
root@localhost:~# su postgres -c "/usr/lib/postgresql/8.3/bin/postgres -D /usr/lib/postgresql/8.3/data"
LOG: database system was shut down at 2009-11-07 00:37:47 EST
LOG: autovacuum launcher started
LOG: database system is ready to accept connections
FATAL: database "root" does not exist
FATAL: database "saju" does not exist
================================================5
* take a new terminal and type following command.
saju@localhost:/home/root$ psql -U postgres
could not change directory to "/home/root"
Welcome to psql 8.3.6, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
postgres=#
================================================6
* To solve phpPgAdmin Login Problem 'Login disallowed for security reasons' set $conf['extra_login_security'] to false;.
* To solve postgres user login problem 'Login disallowed for security reasons' in phpPgAdmin.
vim /var/www/phpPgAdmin/conf/config.inc.php
$conf['extra_login_security'] = false;
================================================7
* To access postgres database from terminal.
periyar:~# psql dbname -U username
Welcome to psql 8.3.6, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
dbname=#
================================================8
* Postgresql database Backup and Restore commands.
Postgresql database backup command.
----------------------------------
#pg_dump -d shopdb -U username -f /home/user/shopdbbkp.txt
Postgresql database restore command.
-----------------------------------
#create database shopdb
#psql shopdb -U username -f /home/user/shopdbbkp.txt
================================================
No comments:
Post a Comment