// Richard Hart / Hates_

Quickly close database connections on the command line

programming
Share

One slightly annoying thing about Postgres over MySQL is that trying to reset a database with

rake db:migrate:reset
fails if there are connected clients and as I use Pow for development, killing the process doesn’t always free up the connections.

To get around this you can quickly kill all connections with this command:


ps x -o pid,command | grep postgres | grep my_database | cut -f 1 -d " " | xargs kill