简体   繁体   English

忘记了我的postgres用户密码以连接服务器

[英]Can't remember my postgres user password to connect server

I'm working in this Django app but I stopped working on it per two weeks, so my computer was off during this time. 我正在使用此Django应用程序,但每两周就停止工作,因此这段时间我的计算机处于关闭状态。 Now I want to work on it again this error appear to me over and over again in my command line, I opened pgAdmin and found is because I need my password for my postgres user and I can't remember it. 现在,我想再次处理该错误,我在命令行中反复出现此错误,我打开pgAdmin,发现这是因为我需要我的postgres用户密码,但我不记得了。 Does anybody knows how to fix this? 有人知道如何解决此问题吗?

在此处输入图片说明

The postgres account has no password (by default). postgres帐户没有密码(默认情况下)。 You should not be using this account to connect to the database. 您不应该使用此帐户连接到数据库。 If you are using a linux distribution, you can execute the following command in order to create another user account that you can use for login: 如果使用的是Linux发行版,则可以执行以下命令,以创建另一个可用于登录的用户帐户:

sudo -u postgres psql -c "create user newuser with superuser password 'new_password_123';" sudo -u postgres psql -c“使用超级用户密码'new_password_123'创建用户newuser;”

This way you will create a user with username newuser and password new_password_123 这样,您将使用用户名newuser和密码new_password_123创建一个用户。

There is also another way to reset the password that is explained in this question. 还有另一种方法来重置密码, 问题对此进行了说明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM