## postgresqlの確認
```
(*^ - ^)❯postgres --version
postgres (PostgreSQL) 10.0
```
ない場合は、`brew install postgresql'
---
### postgresqlの設定
**DBの設定**
`initdb /usr/local/var/postgres -E utf8`
**パーミッションのエラーが出た場合**
```
The files belonging to this database system will be owned by user "ユーザー名".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /usr/local/var/postgres ... initdb: could not change permissions of directory "/usr/local/var/postgres": Operation not permitted
```
`sudo chown -R `whoami` /usr/local`
権限を変えておく。
[参考リンク](https://stackoverflow.com/questions/34797997/initdb-usr-local-var-postgres-on-el-capitan)
**サーバーの起動**
`brew services start postgresql`
**データベースの確認**
`psql -l`
ユーザーを作成しておくと良いかも
---
### dbextの設定
```
Plug 'vim-scripts/dbext.vim', { 'for': 'sql' }
let g:dbext_default_profile_psql = 'type=PGSQL:host=localhost:port=5432:dbname=squat:user=kage'
let g:dbext_default_profile = 'psql'
let dbext_default_buffer_lines=30
```
$HOMEに.pgpassを作成しておく
`hostname:port:database:username:password`
一行で良い。
.pgpassに関して、warningが出るようであれば`chmod 600 .pgpass`しておけば警告は消える。
コマンドに関しては、リンクを参照
[Qiita記事](https://qiita.com/0829/items/ce92a752bf832a06bcf2)