---
name: "destroyuser"
section: "1"
platform: "linux"
package: "postgresql-client"
version: "6.5.3-27"
release: "Debian 2.2 (Potato)"
platforms: ["linux"]
url: "https://new.carta.tech/destroyuser"
---

# destroyuser(1)

destroy a Postgres user and associated databases

## NAME

destroyuser - destroy a Postgres user and associated databases

## SYNOPSIS

**destroyuser** \[**-a** system\] \[**-h** host\] \[**-p** port\] **-u** \[username\]

## DESCRIPTION

*Destroyuser* destroys an existing Postgres user and the databases for which that user is database administrator.  Only users with “usesuper” set in the “pg\_shadow” class can destroy new Postgres users.  As shipped, the user “postgres” can destroy users.

*Destroyuser* is a shell script that invokes *psql*. Hence, a *postmaster* process must be running on the database server host before *destroyuser* is executed.  In addition, the PGOPTION and PGREALM environment variables will be passed on to *psql* and processed as described in  *[psql(1)](/psql/1.md).*

The optional argument *username* specifies the name of the Postgres user to be destroyed.  (The invoker will be prompted for a name if none is specified on the command line.)

*Destroyuser* understands the following command-line options:

- **-a** system

  Specifies an authentication system *system* to use in connecting to the  *postmaster* process.  This option no longer has any effect.

- **-h** host

  Specifies the hostname of the machine on which the  *postmaster* is running.  Defaults to using local Unix domain sockets.

- **-p** port

  Specifies the TCP/IP port or local Unix domain socket file extension on which the *postmaster* is listening for connections.  Defaults to 5432, or the value of the PGPORT environment variable (if set).

- **-u**

  Use password authentication. Prompts for username and password.

## INTERACTIVE QUESTIONS

Once invoked with the above options, *destroyuser* will warn you about the databases that will be destroyed in the process and permit you to abort the removal of the user if desired.

## SEE ALSO

drop\_user(l), [createuser(1)](/createuser/1.md), [psql(1)](/psql/1.md), [postmaster(1)](/postmaster/1.md).

## DIAGNOSTICS

- **Error: Failed to connect to backend (host=***xxx***, port=***xxx***)**

  *Destroyuser* could not attach to the  *postmaster* process on the specified host and port.  If you see this message, ensure that the *postmaster* is running on the proper host and that you have specified the proper port.  If your site uses an authentication system, ensure that you have obtained the required authentication credentials.

- **user “***username***” is not in “pg\_shadow”**

  You do not have a valid entry in the relation “pg\_shadow” and cannot do anything with Postgres at all; contact your Postgres site administrator.

- *username* **cannot delete users.**

  You do not have permission to delete users; contact your Postgres site administrator.

- **user “***username***” does not exist**

  The user to be removed does not have an entry in the “pg\_shadow” class.

- **database access failed**

  - **destroydb on** *dbname* **failed - exiting**

  - **delete of user** *username* **was UNSUCCESSFUL**

  An internal error occurred in  *psql* or the backend server.  Contact your Postgres site administrator to ensure that the files and database entries associated with the user and his/her associated databases are completely removed.

## NOTE

The command internally runs *drop user* from *psql* connected to the *template1* database to perform the operation.

## BUGS

Use of the **-u** option will cause multiple prompts for username and password, since *psql* is called multiple times.
