sh psql-cheatsheet.md

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh psql-cheatsheet.md相关的知识,希望对你有一定的参考价值。

// Remote Access PSQL
```bash
psql --host=host --port=5432 --username=username@servername --dbname=postgres
```

// create user
```bash
sudo -u postgres createuser <username>
```

// create database
```bash
sudo -u postgres createdb <dbname>
```

// grant privilleges
```bash
sudo -u postgres psql
psql=# alter user <username> with encrypted password '<password>';
```

// from psql
```bash
CREATE DATABASE yourdbname;
CREATE USER youruser WITH ENCRYPTED PASSWORD 'yourpass';
GRANT ALL PRIVILEGES ON DATABASE yourdbname TO youruser;
```
psql -p 5432 -h localhost -U postgres
#check size db
SELECT pg_size_pretty( pg_database_size('ppda_datalake'));

#
#postgresql.conf
listen_addresses = '*' 

#pg_hba.conf
host all all 0.0.0.0/0 md5

以上是关于sh psql-cheatsheet.md的主要内容,如果未能解决你的问题,请参考以下文章