

- #LINUX POSTGRESQL CREATE DATABASE HOW TO#
- #LINUX POSTGRESQL CREATE DATABASE INSTALL#
- #LINUX POSTGRESQL CREATE DATABASE PASSWORD#
Ok, by doing a deep research I come with this solution that works but miss some things that I need too.
#LINUX POSTGRESQL CREATE DATABASE HOW TO#
I need some advice on this bash script since I don't know how to get it, can any give me some help? sql files but don't know if -filename allow more than one file at time. Create some schemas on the DB ( I don't know if I should select the DB first)ĬREATE SCHEMA nomencladores AUTHORIZATION postgres ĬREATE SCHEMA negocio AUTHORIZATION postgres ĬREATE SCHEMA usuarios_externos AUTHORIZATION postgres Īnd finally I should load around 10.
#LINUX POSTGRESQL CREATE DATABASE PASSWORD#
Psql -u postgres -w // this line should connect to PostgreSQL asking for a password since I not found other way to pass the password on that lineĬREATE DATABASE sis_db WITH OWNER = postgres ENCODING = 'UTF8' TABLESPACE = pg_default LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8' CONNECTION LIMIT = -1 // create the DB Basically this is the repetitive tasks I do all the time, from a pgAdmin GUI: #!/bin/sh

So I need to build some kind of bash script for help me out on this. I've a PostgreSQL server and since I'm developing a web application I need to drop, create and fill some tables all the time and this is a tedious process.
#LINUX POSTGRESQL CREATE DATABASE INSTALL#
If you want it entirely independent of system packages, as you probably do if you don't control the system, you should compile PostgreSQL from source or use the binary installer to install inside your home directory.I need some advice creating a script for help me with repetitive task I do all the time on a development environment. This is important because if you uninstall (say) PostgreSQL 9.4 and install 9.6, your copy in your home dir will stop working. Note that this approach still uses the system packages for PostgreSQL. They vary depending on environment and version so I can't give details here it's different for GNOME 3, Unity (ubuntu), KDE, XFCE, etc. To autostart it when you log in when it's set up in your home directory you'd have to use your desktop environment's run-at-startup features. To stop it: pg_ctl -D $HOME/my_postgres -w stopīut you can also just shut down without stopping it, it doesn't care and will recover safely when you start it next. To make psql etc connect to your postgres by default, edit your ~/.bashrc to add something like export PGPORT=5434īut note that'll also affect the default port for connections to other hosts. (If you changed unix_socket_directories you'll also want to specify the path you gave, like -h /home/myuser/postgres_socket.) To connect to it, specify the port you chose: psql -p 5434. To start it: pg_ctl -D $HOME/my_postgres -w start But it's simpler to just use a different port.)

(If you want to limit access strictly to you, you can instead set listen_addresses = '' and unix_socket_directories = /home/myuser/postgres_socket or whatever. You'll then need to edit nf to change the port to a non-default one, since your system probably runs its own postgres on the default port 5432. To create the new PostgreSQL instance with the superuser equal to your username, data directory in your home directory, and md5 auth enabled by default, use: initdb -D $HOME/my_postgres -A md5 -U $USER You must use only PostgreSQL's own tools.

You can't use the Ubuntu init scripts, wrapper tools like pg_ctlcluster, etc if you do this. You can run PostgreSQL without root privs by creating a new instance (which PostgreSQL calls a "cluster") and starting it.
