O'Reilly logo

PostgreSQL 9 Administration Cookbook by Hannu Krosing, Simon Riggs

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Preventing new connections

In certain emergencies, you may need to lock down the server completely, or just prevent specific users from accessing the database. It's hard to foresee all the situations in which you might need to do this, so we present a range of options.

How to do it...

Connections can be prevented in a number of ways as follows:

  • Pause/Resume the session pool. See recipe on controlling connection pools
  • Stop the server! See the earlier recipe, but it is not recommended.
  • Restrict connections to zero for a specific database by setting the connection limit to zero.
    ALTER DATABASE foo_db CONNECTION LIMIT 0;
    

    This will limit normal users from connecting to that database, though it will still allow superuser connections.

  • Restrict connections ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required