Knowledgebase

Question About Servers

How to Change an Odoo Database Name Print

  • 0

Odoo does not have a built-in way to rename a database from its web interface. You can rename one from the command line, but you need to rename two things: the PostgreSQL database and the filestore folder that holds your attachments. If you only rename the database, Odoo will lose track of every uploaded file, image and PDF.

Note: take a full backup of the database before you start. See How to Backup and Restore a Database in Odoo.

Step 1: Connect to Your Server

Connect to your server over SSH as a user with sudo privileges.

Step 2: Find Your Odoo Service and Configuration File

The service name and config file path depend on how Odoo was installed. List the Odoo services on the server:

systemctl list-units --type=service | grep -i odoo

Then check which config file that service uses. Replace odoo with your service name:

systemctl cat odoo | grep ExecStart

The path after -c is your configuration file, for example /etc/odoo.conf.

Step 3: Stop Odoo

PostgreSQL will not rename a database while Odoo is connected to it, so stop the service first:

sudo systemctl stop odoo

Step 4: Rename the PostgreSQL Database

Replace old_db and new_db with the current and new names:

sudo -u postgres psql -c 'ALTER DATABASE "old_db" RENAME TO "new_db";'

If you see an error saying the database is being accessed by other users, check that every Odoo service using it is stopped, then try again.

Step 5: Rename the Filestore Folder

Odoo stores attachments in a folder named after the database. Find it with:

sudo find / -type d -path "*/filestore/old_db" 2>/dev/null

Rename the folder to match the new database name. Use the path the previous command returned, for example:

sudo mv /opt/odoo/.local/share/Odoo/filestore/old_db /opt/odoo/.local/share/Odoo/filestore/new_db

Step 6: Update the Configuration File

Check whether the config file refers to the old name:

sudo grep -E "db_name|dbfilter" /etc/odoo.conf

If db_name or dbfilter contains the old name, change it to the new one. For example:

sudo sed -i 's/^db_name = old_db/db_name = new_db/' /etc/odoo.conf

Step 7: Start Odoo and Test

sudo systemctl start odoo
sudo systemctl status odoo

Log in and open a record that has an attachment or image, such as a product with a photo. If the image loads, the filestore was renamed correctly.

Next Steps

If you use scheduled backup scripts or cron jobs that reference the database name, update those as well. If you would rather have our team handle changes like this, our managed Odoo hosting includes 24/7 US-based support.


Was this answer helpful?

« Back

Enterprise-Grade Hardware

  • Samsung
  • Juniper
  • Western Digital
  • Supermicro
  • LSI
  • Intel
  • R1Soft Backups
  • cPanel
  • MySQL
  • Parallels
  • HP Partner