mirror of
https://github.com/supabase/supabase.git
synced 2026-05-24 04:00:47 +08:00
135 lines
2.4 KiB
Plaintext
135 lines
2.4 KiB
Plaintext
---
|
|
id: connection-strings
|
|
title: "Connection Strings"
|
|
slug: connection-strings
|
|
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/postgres.yml
|
|
---
|
|
|
|
import Tabs from '@theme/Tabs';
|
|
import TabsPanel from '@theme/TabsPanel';
|
|
|
|
There are various ways to connect to your database, depending on the configuration of your Postgres instance and the tool which you are connecting with.
|
|
|
|
|
|
<Tabs
|
|
defaultActiveId="sql"
|
|
groupId="reference/postgres"
|
|
values={[{ label: 'SQL', value: 'sql' }]}>
|
|
|
|
<TabsPanel id="sql" label="sql">
|
|
|
|
```bash
|
|
postgres://postgres:postgres@localhost:5432/postgres
|
|
# or
|
|
postgresql://postgres:postgres@localhost:5432/postgres
|
|
```
|
|
|
|
|
|
</TabsPanel>
|
|
|
|
</Tabs>
|
|
|
|
|
|
|
|
|
|
|
|
## Notes
|
|
|
|
- [Official Documentation](https://www.postgresql.org/docs/current/libpq-connect.html).
|
|
- Avoid using special characters usernames and passwords. If you use special characters in a connection URL, you'll need to URL encode any special characters.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
### Basic connection string
|
|
|
|
If you're using a default setup, your postgres connection string will likely be in the format:
|
|
|
|
`postgres://{user}:{password}@{host}:{port}/{database_name}`
|
|
|
|
|
|
<Tabs
|
|
defaultActiveId="sql"
|
|
groupId="reference/postgres"
|
|
values={[{ label: 'SQL', value: 'sql' }]}>
|
|
|
|
<TabsPanel id="sql" label="sql">
|
|
|
|
```bash
|
|
postgres://postgres:postgres@localhost:5432/postgres
|
|
# or
|
|
postgresql://postgres:postgres@localhost:5432/postgres
|
|
```
|
|
|
|
|
|
</TabsPanel>
|
|
|
|
</Tabs>
|
|
|
|
### JDBC
|
|
|
|
See full [documentation](http://jdbc.postgresql.org/documentation/head/connect.html).
|
|
|
|
<Tabs
|
|
defaultActiveId="sql"
|
|
groupId="reference/postgres"
|
|
values={[{ label: 'SQL', value: 'sql' }]}>
|
|
|
|
<TabsPanel id="sql" label="sql">
|
|
|
|
```bash
|
|
jdbc:postgresql://{host}:{port}/{database_name}
|
|
```
|
|
|
|
|
|
</TabsPanel>
|
|
|
|
</Tabs>
|
|
|
|
### ADO.NET
|
|
|
|
See full [documentation](http://npgsql.projects.postgresql.org/docs/manual/UserManual.html).
|
|
|
|
<Tabs
|
|
defaultActiveId="sql"
|
|
groupId="reference/postgres"
|
|
values={[{ label: 'SQL', value: 'sql' }]}>
|
|
|
|
<TabsPanel id="sql" label="sql">
|
|
|
|
```bash
|
|
Server=host;Port=5432;User Id=username;Password=secret;Database=database_name;
|
|
```
|
|
|
|
|
|
</TabsPanel>
|
|
|
|
</Tabs>
|
|
|
|
### PHP
|
|
|
|
See full [documentation](http://php.net/manual/en/book.pgsql.php).
|
|
|
|
<Tabs
|
|
defaultActiveId="sql"
|
|
groupId="reference/postgres"
|
|
values={[{ label: 'SQL', value: 'sql' }]}>
|
|
|
|
<TabsPanel id="sql" label="sql">
|
|
|
|
```bash
|
|
host=hostname port=5432 dbname=databasename user=username password=secret
|
|
```
|
|
|
|
|
|
</TabsPanel>
|
|
|
|
</Tabs> |