Help

2

How can I delete databases when 'drop' from Manage Databases says the operation was successful but the database is still there?

Avatar
Riccardo Pasquali

I have recently migrated my company openerp 7 data to a new server (same open ERP, apps & modules etc.).  This has taken me a few attempts and I have created a couple of 'test' databases to check that all was restored successfully.


I am now trying to delete the tests databases using the 'Drop' function in the Manage Database window.  However, despite getting a message to say it was successful, the databases are all still there, leaving my users to having to select one.

This is not ideal as it will likely give rise to confusion.

Can anyone please explain how to get rid of the 'test' databases and to any reference in the manage database drop down please?

Avatar
Discard
1 Answer
2
Avatar
Papirkriger.no
Best Answer

You're not specifying which OS your odoo-server (or dedicated postgresql-server) runs on, so I'm gonna assume it's Ubuntu Linux or equivalent.

1. SSH inn to your server.

2. Change user to your database-user (name of database-user was set during initial setup of system):
sudo su postgres

3. Start Psql:
psql

4. List available databases:
\l

5. Drop database:
drop database your_db_name_to_remove;

5.1. If you get a message something like "Unable to drop database. DETAIL: There are 5 other sessions using the database postgres", you need remove the active connections by typing:
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'your_db_name_to_remove' AND pid != pg_backend_pid();

5.2 IF on postgres 8.4-9.1, run the following instead:
SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE procpid <> pg_backend_pid() AND datname = 'your_db_name_to_remove';

6. Repeat for all test-databases.

7. Exit psql
\q

8. Exit databaseuser-userspace:
exit

9. Restart odoo-server, e.g;
sudo service odoo-server restart

10. Exit ssh
exit

1 Comment
Avatar
Discard
Avatar
Xavier Brochard
-

Don't forget ";" at the end of lines in psql command. It's also better to enclose db_name in double quotes (because of uppercase, special characters, etc.)