4

I'm new to PostgreSQL.I'm using postgreSQL locally. I used it last time without any issues. Now, when I try login with my login credentials it shows the account is locked message all the time. enter image description here

2
  • This needs more information: 1) How did you install Postgres? 2) Postgres version? 3) Who setup pgAdmin? 4) Can you log into the server via psql. This by the way is an pgAdmin issue not a Postgres one.
    – Adrian Klaver
    Commented Sep 4, 2021 at 15:01
  • 1. I followed this tecmint.com/install-postgresql-and-pgadmin-in-ubuntu blog to install postgresql and pgadmin4. 2). Postgres version psql (PostgreSQL) 13.4 (Ubuntu 13.4-1.pgdg20.04+1) 3. I did setup the pgadmin using following command. sudo apt install pgadmin4 . i setup the initial mail and password. 4). I think i can log in psql. if i'm not wrong. ``` sudo su - postgres [sudo] password for gowtham: postgres@Gowtham-PC:~$ psql postgres=# CREATE USER tecmint WITH PASSWORD 'securep@wd'; ERROR: role "tecmint" already exists ```
    – gowtham6672
    Commented Sep 4, 2021 at 15:29

5 Answers 5

6

According to the pgadmin documentation there are two ways to unlock the user.

1. Updating SQLite DB (pgAdmin4.db):

Locate the pgAdmin4.db file and open it using any DB Browser (or DB Browser for SQLite)

After opening the DB file, head towards ‘Execute SQL’ section. Run below query :

UPDATE USER SET LOCKED = false, LOGIN_ATTEMPTS = 0 WHERE USERNAME = <YOUR_EMAIL_ID>

And make sure the query changes are committed.

2. Increase the MAX_LOGIN_ATTEMPTS in the pgadmin configuration file config.py or preferably add a line in config_local.py

MAX_LOGIN_ATTEMPTS = 5
2
  • 2
    the file located at /var/lib/pgadmin4/pgadmin4.db
    – buncis
    Commented Feb 5, 2022 at 3:53
  • 5
    How can I open it in a docker container? Commented Nov 21, 2022 at 19:28
2

As @alfredo138923 explains, you should find pgadmin4.db on your system and run a query to update the USER attempts and unlock the application for the specific user account.

But the correct SQL query must be fixed. The query parameter value must use single quotes, otherwise an error will be returned.

UPDATE USER SET LOCKED = false, LOGIN_ATTEMPTS = 0 WHERE USERNAME = '<YOUR_EMAIL>'

An example on the shell command line might be (i use Ubuntu 20.04)*:

sqlite3 pgadmin4.db "UPDATE USER SET LOCKED = false, LOGIN_ATTEMPTS = 0 WHERE USERNAME = '[email protected]';" ".exit"

*Before using sqlite3 from the command line, you need to install it as below.

apt-get install sqlite3
0

These solutions work very well, but if you've deployed pgadmin to a cluster or in a container, where you don't have sudo rights and the sqlite CLI tool is not installed, then you can also just use python to execute the query:

Back up your db before executing this! cp /var/lib/pgadmin/pgadmin4.db /var/lib/pgadmin/pgadmin4.db.backup

import sqlite3

db_path = '/var/lib/pgadmin/pgadmin4.db'

query = "update user set locked = false, login_attempts = 0 where username = '<admin_email>';"

conn = sqlite3.connect(db_path)

cursor = conn.cursor()

cursor.execute(query)

conn.commit()

print('User should be unlocked now. Changes commited to the DB.')

Note: this script doesn't have any error checking!

Tested this with https://artifacthub.io/packages/helm/runix/pgadmin4/1.2.20 Which is using image https://hub.docker.com/r/dpage/pgadmin4/

New contributor
Zsolt András Patka is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
-1

Steps to Solve this Issue

First Locate the pgAdmin4.db in Ubuntu 20.04 you find following path

cd /var/lib/pgadmin

then run the following command

sqlite3 pgadmin4.db there might be two files but choose the file of heavy size

SQLite will be opened

now than run the command UPDATE USER SET LOCKED = false, LOGIN_ATTEMPTS = 0 WHERE USERNAME = '<YOUR_EMAIL>'

now you can login

-3

enter image description hereUnder Ubuntu 20.4 you must find the file vi /usr/pgadmin4/web/config.py change the MAX_LOGIN_ATTEMPTS =0 restart your server systemctl restart postgresql OR stop it then start it again systemctl stop postgresql systemctl start postgresql

1
  • This may explain how to prevent lock-outs in the future, but doesn't say how to unlock a user that's already locked out. And do you really need to restart Postgres when changing pgAdmin configuration?
    – mustaccio
    Commented Dec 30, 2021 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.