hiltgeek.blogg.se

Create new database in postgres
Create new database in postgres





create new database in postgres create new database in postgres

Often in *nix systems the installer setups up PGDATA variable for you so you don't have to specify the directory. You did not specify if this is a test machine or planned for prod, but you probably should use the service command to run the initdb and after that sudo to the postgres user to run the createdb. Reference: initdb (PostgreSQL Documentation) A database cluster is a collection of databases that are managed by a single server instance. Initdb creates a new PostgreSQL database cluster. When you ran your initdb you were just initializing the folder /var/lib/pgsql/test to hold ALL future databases, but you did not actually create ANY database.

create new database in postgres

That does not create a new database.Ĭreatedb is used for each DB you want to create. Initdb is used once to initialize a DB environment directory structure. Psql: FATAL: database "/var/lib/pgsql/test" does not exist I also tried to backup the new database but that too fails: sudo -u postgres psql -d /var/lib/pgsql/test -c "SELECT pg_start_backup('test') " Template1 | postgres | UTF8 | en_CA.UTF-8 | en_CA.UTF-8 | =c/postgres +Ĭan someone explain what's wrong? Do I have to register my new test database with PostgreSQL somehow? Template0 | postgres | UTF8 | en_CA.UTF-8 | en_CA.UTF-8 | =c/postgres + Postgres | postgres | UTF8 | en_CA.UTF-8 | en_CA.UTF-8 | Name | Owner | Encoding | Collate | Ctype | Access privileges If I then ask psql to list the databases, but my 'test' database is missing: pgsql]# sudo -u postgres psql -l Pg_ctl -D /var/lib/pgsql/test -l logfile start You can now start the database server using: auth-local and -auth-host, the next time you run initdb. You can change this by editing pg_hba.conf or using the option -A, or WARNING: enabling "trust" authentication for local connections Performing post-bootstrap initialization. Selecting dynamic shared memory implementation. The default text search configuration will be set to "english".Ĭreating directory /var/lib/pgsql/test. The default database encoding has accordingly been set to "UTF8". The database cluster will be initialized with locale "en_CA.UTF-8". This user must also own the server process. The files belonging to this database system will be owned by user "postgres".

create new database in postgres

I created a new PostgreSQL 9.5 database as follows: pgsql]# sudo -u postgres initdb -D /var/lib/pgsql/test







Create new database in postgres