Skip to Content
Menu
This question has been flagged
2 Replies
21790 Views

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
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

Avatar
Discard

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.)

Best Answer

close the application and open psql from terminal

$ psql
$ drop database "your_database_name";


Avatar
Discard

When using only SQL to drop an Odoo database, the filestore associated to the database becomes dead wood on the filesystem. AVOID.