Ubuntu 20.04运行pgAdmin4遇重复列名OperationalError问题求助
Hey there, I’ve seen this exact issue a handful of times—it’s almost always down to leftover data from a previous pgAdmin4 installation conflicting with your new setup. Let’s break down what’s happening and how to fix it quickly:
What’s Causing the Error?
Your error log shows that pgAdmin4’s migration script is trying to add a hostaddr column to the server table in its SQLite config database (pgAdmin4.db), but that column already exists. This happens because you’re reusing the same ~/.pgAdmin/ directory from a prior install, where the database already has that column, but the new version’s migration doesn’t account for it.
Step-by-Step Fix
1. Kill any running pgAdmin4 processes first
Make sure no pgAdmin4 instances are holding onto the database file:
pkill -f pgadmin4.py
2. Backup your old config (optional but smart)
If you don’t want to lose your saved server connections, backup the old database before making changes:
mv ~/.pgAdmin/pgAdmin4.db ~/.pgAdmin/pgAdmin4.db.backup
3. Clear the conflicting database
You can either delete just the problematic database file:
rm ~/.pgAdmin/pgAdmin4.db
Or wipe the entire pgAdmin data directory if you don’t need any old settings:
rm -rf ~/.pgAdmin/
4. Reinitialize pgAdmin4
Head back to your virtualenv and rerun the pgAdmin4 startup script. It’ll create a fresh, clean database and run the migrations without conflicts:
cd pgadmin && source bin/activate python /pgadmin/pgadmin/lib/python3.8/site-packages/pgadmin4/pgadmin4.py
Bonus: Restoring Old Connections (If You Backed Up)
If you saved the old database and want to get your connections back:
- Launch the new pgAdmin4 once to generate the fresh database structure
- Use a tool like
sqlite3to open both the old backup and new database - Copy the rows from the old
servertable to the new one, making sure to omit thehostaddrcolumn (since the new table already has it)
内容的提问来源于stack exchange,提问作者farhad.a

