postgresqlHow can I set up and configure a PostgreSQL server?
- Install PostgreSQL using a package manager:
sudo apt-get install postgresql
- Create a database user:
sudo -u postgres createuser -s <username>
- Create a new database:
sudo -u postgres createdb <dbname>
- Configure authentication for the user:
sudo -u postgres psql
\password <username>
- Allow remote connections (optional):
Edit the file
/etc/postgresql/<version>/main/pg_hba.conf
and add the line:
host <dbname> <username> <IP address> md5
-
Edit the PostgreSQL configuration file
postgresql.conf
to allow remote connections: Change the linelisten_addresses = 'localhost'
tolisten_addresses = '*'
-
Restart the PostgreSQL service:
sudo service postgresql restart
Helpful links
More of Postgresql
- How can I use PostgreSQL and ZFS snapshots together?
- How can I use PostgreSQL with YAML?
- How can I extract the year from a PostgreSQL timestamp?
- How can I extract the year from a date in PostgreSQL?
- How do I use PostgreSQL's XMLTABLE to parse XML data?
- How do I convert a string to lowercase in PostgreSQL?
- How can I convert XML data to a PostgreSQL table?
- How can I set a PostgreSQL interval to zero?
- How can I troubleshoot zero damaged pages in PostgreSQL?
- How do I use PostgreSQL ZonedDateTime to store date and time information?
See more codes...