Editing Psql

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
 
{{lowercase}}
 
{{lowercase}}
 
[[wikipedia:psql]] command line tool to connect and execute queries against a [[PostgreSQL]] (port 5432) or [[Amazon Redshift]] database (port [[5439]]).
 
[[wikipedia:psql]] command line tool to connect and execute queries against a [[PostgreSQL]] (port 5432) or [[Amazon Redshift]] database (port [[5439]]).
* https://www.postgresql.org/docs/current/app-psql.html
 
  
 
* Ubuntu installation: <code>[[apt install]] postgresql-client-12</code>
 
* Ubuntu installation: <code>[[apt install]] postgresql-client-12</code>
* [[Amazon Linux 2]]:  
+
* [[Amazon Linux 2]]: <code>[[yum install postgresql.x86_64]]</code> (PostgreSQL client programs)
** <code>[[yum install postgresql.x86_64]]</code> (PostgreSQL client programs)
 
** <code>[[sudo amazon-linux-extras install postgresql10]]</code>
 
  
 
* macOS: <code>[[brew install libpq]]</code>
 
* macOS: <code>[[brew install libpq]]</code>
Line 16: Line 13:
  
 
[[Connect to remote database]]:
 
[[Connect to remote database]]:
* <code>[[psql --host]]=mypostgresql.c6c8mwvfdgv0.us-west-2.rds.amazonaws.com --port=[[5432]] --username=awsuser --password [[--dbname]]=mypgdb</code>  
+
* <code>psql --host=mypostgresql.c6c8mwvfdgv0.us-west-2.rds.amazonaws.com --port=[[5432]] --username=awsuser --password [[--dbname]]=mypgdb</code>  
  
 
* <code>psql -h localhost -U YOUR_USERNAME DB_NAME</code>
 
* <code>psql -h localhost -U YOUR_USERNAME DB_NAME</code>
Line 26: Line 23:
  
 
* <code>[[psql postgres]]</code>
 
* <code>[[psql postgres]]</code>
 
* <code>[[psql]] "postgres://[[tsdbadmin]]@xjsgtxszr.u2gst5tl.vpc.tsdb.forge.timescale.com:5432/tsdb?[[sslmode]]=require"</code>
 
  
  
Line 69: Line 64:
 
  psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
 
  psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
 
  Is the server running locally and accepting connections on that socket?
 
  Is the server running locally and accepting connections on that socket?
  Solution: Check if your local database is runnning or provide [[remote server to connect]] using [[--host]] or [[service]] options defined in your <code>[[$HOME/.pg_service.conf]]</code> file.
+
  Solution: Check if your local database is runnning or provide [[remote server to connect]] using [[--host]] or [[service]] options defined in your <code>[[$HOME/.pg service.conf]]</code> file.
  
 
  psql service=pro
 
  psql service=pro
  psql: error: could not connect to server: [[Connection refused]] Is the server running on host "your_rds_instance.eu-central-1.[[rds.amazonaws.com]]" (7.123.109.22) and accepting TCP/IP connections on port [[5432]] ?
+
  psql: error: could not connect to server: [[Connection refused]] Is the server running on host "your_rds_instance.eu-central-1.[[rds.amazonaws.com]]" (7.123.109.22) and accepting
 +
        TCP/IP connections on port [[5433]] ?
  
 
  psql
 
  psql
Line 80: Line 76:
  
 
  psql
 
  psql
  psql: error: [[connection to server on socket]] "/tmp/.s.PGSQL.5432" failed: FATAL:  database "your-db" [[does not exist]]
+
  psql: error: [[connection to server on socket]] "/tmp/.s.PGSQL.5432" failed: FATAL:  database "your-db" does not exist
 
Solution: [[createdb (command)|createdb]] your-db && psql your-db
 
 
 
psql
 
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL:  database "user" does not exist
 
  
 
== Options ==
 
== Options ==
Line 104: Line 95:
 
* <code>[[aws rds describe-db-instances]]</code>
 
* <code>[[aws rds describe-db-instances]]</code>
 
* <code>[[heroku psql]]</code>
 
* <code>[[heroku psql]]</code>
* [[psql: SCRAM authentication requires libpq version 10 or above]]
 
* [[Database management]]: <code>[[mysql (command)|mysql]], [[mariadb (command)|mariadb]]</code>
 
  
 
== See also ==
 
== See also ==

Please note that all contributions to wikieduonline may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Wikieduonline:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)

Advertising: