Preventing new connections
In certain emergencies, you may need to lock down a server completely, or just prevent specific users from accessing a database. It’s hard to foresee all the situations where you may need to do this, so we will present a range of options.
How to do it…
Connections can be prevented in several 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 (although this is not recommended)! See the Stopping the server safely and quickly and the Stopping the server in an emergency recipes.
- Restrict the connections for a specific database to 0 by setting the connection limit to
0
:ALTER DATABASE foo_db CONNECTION LIMIT 0;
This will limit normal users from connecting to that database, although it will still allow superuser connections.
- Restrict the connections for a specific...