【SQL】pgAdminで新しいデータベースの作成時のエラー

pgAdminを強制終了すると、たまにサーバ側にプロセスが残ったままになり
接続しなおしても

source database "template1" is being accessed by other users

というエラーを吐き新しいデータベースの作成や削除が出来なくなることがある

そんな時は、データベースのあるサーバで
残っているプロセスを削除する

$ ps -aux
postgres 28030  0.0  0.2 86128 5052 ?        S    Aug24   0:00 postgres: meta template1 127.0.0.1 idle
postgres 28151  0.0  0.3 87284 6040 ?        S    Aug24   0:00 postgres: meta meta 127.0.0.1 idle
postgres 30201  0.0  0.3 87292 6868 ?        S    Aug24   0:00 postgres: meta aichi 127.0.0.1 idle
$ sudo kill -9 28030

ps -aux
でプロセスの一覧を表示しpostgresのプロセスidを確認して
sudo kill -9 28030

  • 9は確実に消すオプション

で上記のエラーは解消される