如何删除postgresql用户

时间:2017-07-26 06:44:27

标签: postgresql

我跟着this tutorial打了一个拼写错误,我应该为我的django应用创建一个用户来连接;

我应该运行su - postgres -c "createuser www-data -P"但是我跑了su - postgres -c "createuser www-dtata -P"

我不想继续,直到我删除该用户,我不知道该命令。我在搜索后找到并尝试DROP USER,但终端返回了-su: DROP: command not found

3 个答案:

答案 0 :(得分:3)

运行sudo su - postgres -c "dropuser www-dtata"

答案 1 :(得分:1)

您可以使用dropuser控制台工具(请参阅https://www.postgresql.org/docs/current/static/app-dropuser.html):

su - postgres -c "dropuser www-dtata"

或使用DROP USER SQL查询(请参阅https://www.postgresql.org/docs/current/static/sql-dropuser.html):

sudo -u postgres psql -c 'DROP USER "www-dtata";'

这两种方法做同样的事情。在SQL版本中,由于其中包含-,您还需要在数据库用户名周围使用双引号。

答案 2 :(得分:-1)

首先运行命令

sudo su

输入用于root访问的用户密码。

然后运行以下命令

su-postgres -c“ dropuser www-dtata”

将不会提示输入密码