Book Image

PostgreSQL 9 Administration Cookbook - Second Edition

Book Image

PostgreSQL 9 Administration Cookbook - Second Edition

Overview of this book

Table of Contents (19 chapters)
PostgreSQL 9 Administration Cookbook Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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 and resume the session pool. See the Setting up a connection pool recipe later in this chapter on controlling connection pools.

  • Stop the server! See the Stopping the server safely and quickly and Stopping the server in an emergency recipes, but this is not recommended.

  • Restrict the connections for a specific database to zero, 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 the connections for a specific user to zero by setting the connection limit to zero (see the Restricting users to only one...