PostgreSQL Connection URL

前端 未结 6 1992
离开以前
离开以前 2020-12-02 03:50

How is the PostgreSQL connection URL formed, when the host is some other computer than the localhost?

I have allowed PostgreSQL to accept requests from outside.

相关标签:
6条回答
  • 2020-12-02 04:28

    If you use Libpq binding for respective language, according to its documentation URI is formed as follows:

    postgresql://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]
    

    Here are examples from same document

    postgresql://
    postgresql://localhost
    postgresql://localhost:5432
    postgresql://localhost/mydb
    postgresql://user@localhost
    postgresql://user:secret@localhost
    postgresql://other@localhost/otherdb?connect_timeout=10&application_name=myapp
    postgresql://localhost/mydb?user=other&password=secret
    
    0 讨论(0)
  • 2020-12-02 04:28
    DATABASE_URL=postgres://{user}:{password}@{hostname}:{port}/{database-name}
    
    0 讨论(0)
  • 2020-12-02 04:36

    Here is the documentation for JDBC, the general URL is "jdbc:postgresql://host:port/database"

    Chapter 3 here documents the ADO.NET connection string, the general connection string is Server=host;Port=5432;User Id=username;Password=secret;Database=databasename;

    PHP documentation us here, the general connection string is host=hostname port=5432 dbname=databasename user=username password=secret

    If you're using something else, you'll have to tell us.

    0 讨论(0)
  • 2020-12-02 04:37

    The following worked for me

    const conString = "postgres://YourUserName:YourPassword@YourHostname:5432/YourDatabaseName";
    
    0 讨论(0)
  • 2020-12-02 04:38

    host or hostname would be the i.p address of the remote server, or if you can access it over the network by computer name, that should work to.

    0 讨论(0)
  • 2020-12-02 04:39

    the connection url for postgres syntax:

    "Server=host ipaddress;Port=5432;Database=dbname;User Id=userid;Password=password;
    

    example:

    "Server=192.168.1.163;Port=5432;Database=postgres;User Id=postgres;Password=root;
    
    0 讨论(0)
提交回复
热议问题