Skip to content

Odoo database access denied

Odoo database access denied

Fix Odoo DB creation error

Introduction

First, this tutorial tackles the Odoo database access denied error and guides you how to Fix Odoo DB creation in Odoo 18. Next, you will learn how to adjust the master password in your odoo.conf file. Then, you will grant proper PostgreSQL rights and restart services. Moreover, we include code snippets and clear steps. Finally, you will find links to official docs for deeper reading: https://www.odoo.com/documentation/18.0/reference/config.html.


Understanding the Odoo database access denied Issue

What Triggers DB Creation Error

First, Odoo blocks new databases when the master password in odoo.conf mismatches web input. Next, the server logs show:

ERROR ? odoo.service.db: Access denied for database creation


Then, Odoo refuses to create a new DB. Moreover, this behavior protects existing data.

Role of the Master Password

First, Odoo uses admin_passwd to secure database operations. Then, the web UI or CLI must supply the same password. Furthermore, Odoo never creates a DB without matching credentials. Consequently, a typo causes the Odoo database access denied message.

How Odoo Checks Master Password

  1. Odoo reads admin_passwd from config.
  2. Odoo matches UI input against admin_passwd.
  3. Odoo throws access denied on mismatch.

Check and Edit Your Odoo Configuration

Locate Your odoo.conf File

First, find the config at:

  • Linux: /etc/odoo/odoo.conf
  • Docker: mounted path /etc/odoo.conf
  • Development: ~/.odoorc

Then, open the file in your favorite editor.

Update the admin_passwd Parameter

First, back up your config:

cp /etc/odoo/odoo.conf /etc/odoo/odoo.conf.bak


Next, open odoo.conf:

[options]
; existing options
admin_passwd = your_old_password

Then, change the line to match your desired master key:

admin_passwd = SuperSecret123


Finally, save and close the file.


How to Fix Odoo DB Creation

Restart Odoo Service

First, restart Odoo to apply your changes:

sudo systemctl restart odoo


Next, confirm status:

sudo systemctl status odoo


Then, ensure no errors appear.

Create Database via Web Interface

First, log in to http://localhost:8069 as database admin. Then, click Manage Databases. Moreover, enter a new name and your updated master password. Finally, click Create Database and confirm success.

Create Database via Command Line

First, use Odoo’s CLI with -d flag:

odoo-bin -c /etc/odoo/odoo.conf -d demo_db --db-filter=demo_db --without-demo=all


Next, watch the console. Then, confirm database creation. Finally, log into http://localhost:8069 using demo_db.


Grant Proper PostgreSQL Permissions

Create a Dedicated PostgreSQL User

First, switch to the postgres user:

sudo su - postgres


Next, create a new role:

createuser --createdb --username postgres --no-createrole --pwprompt odoo_user

Grant Rights on Data Directory

First, exit to root: exit. Then, ensure Odoo owns its data:

sudo chown -R odoo:odoo /var/lib/odoo
sudo chmod -R 750 /var/lib/odoo

Test Direct DB Connection

First, confirm you can connect with your new user:

psql -h localhost -U odoo_user -d postgres

Then, at the prompt:

\l

Next, you should see existing databases.


Advanced Tips and Best Practices

Use Environment Variables for Security

First, avoid storing plain text passwords. Then, set master password in your service file:

[Service]
Environment="ODOO_ADMIN_PASS=SuperSecret123"

Next, reference it in odoo.conf:

admin_passwd = ${ODOO_ADMIN_PASS}

Secure Your Master Password

First, restrict config file access:

sudo chmod 600 /etc/odoo/odoo.conf

Then, ensure only odoo user can read it.

Automate Config Deployment

First, use Ansible or Salt to push odoo.conf. Moreover, apply templates for each environment. Finally, enforce consistent password across nodes.


Debugging and Log Analysis

Enable Detailed Logging

First, set debug in odoo.conf:

log_level = debug


Then, restart Odoo. Next, inspect logs:

sudo tail -f /var/log/odoo/odoo.log

Common Log Messages

  • “Access denied for database creation” → wrong admin_passwd.
  • “could not connect to server” → PostgreSQL down or credentials wrong.

Troubleshooting Checklist

  1. First, verify admin_passwd in odoo.conf.
  2. Next, confirm file permissions on config and data folder.
  3. Then, restart Odoo and PostgreSQL.
  4. Moreover, test master password in web UI and CLI.
  5. Finally, review logs for persistent errors.

Automate Odoo Database Backups

First, you can automate regular backups to protect your data. Then, you avoid data loss if something breaks. Moreover, you keep your backups off-site for extra safety. Finally, you restore quickly when needed.

#!/usr/bin/env bash
# File: /usr/local/bin/odoo_backup.sh
# Description: Dump Odoo DB and compress
DATE=$(date +'%Y%m%d_%H%M%S')
DB_NAME="myodoodb"
BACKUP_DIR="/var/backups/odoo"
mkdir -p $BACKUP_DIR
pg_dump -U odoo_user -h localhost $DB_NAME | gzip > $BACKUP_DIR/${DB_NAME}_${DATE}.sql.gz

Next, make the script executable and schedule it in cron:

chmod +x /usr/local/bin/odoo_backup.sh
crontab -l | { cat; echo "0 2 * * * /usr/local/bin/odoo_backup.sh"; } | crontab -


Then, PostgreSQL creates a compressed dump every night at 2 AM. For more details on pg_dump, see the official PostgreSQL docs: https://www.postgresql.org/docs/current/backup-dump.html.


Troubleshooting Tips and FAQs

Why do I still get “Odoo database access denied” after correcting my password?

First, check for stray spaces or hidden characters in odoo.conf. Then, restart Odoo so it re-reads the file. Moreover, confirm that your master key environment variable matches exactly. Finally, test again via CLI:

odoo-bin -c /etc/odoo/odoo.conf --db-filter=myodoodb -d myodoodb

How do I reset the Odoo master password without editing the file?

First, stop the Odoo service:

sudo systemctl stop odoo


Then, launch the shell with a temporary password override:

ODOO_ADMIN_PASS='NewPass123' odoo-bin -c /etc/odoo/odoo.conf


Next, stop the shell and update your odoo.conf permanently. Finally, restart the service.

What if I cannot access the PostgreSQL server at all?

First, verify the server runs:

sudo systemctl status postgresql


Then, confirm network settings (listen_addresses) in /etc/postgresql/*/main/postgresql.conf. Moreover, grant your Odoo user rights:

GRANT ALL PRIVILEGES ON DATABASE myodoodb TO odoo_user;


Finally, restart PostgreSQL and Odoo.


These additions help you automate backups, prevent data loss, and handle common Odoo database access denied challenges when you Fix Odoo DB creation.

Conclusion

First, you learned to diagnose the Odoo database access denied error. Next, you edited odoo.conf to Fix Odoo DB creation issues. Then, you verified PostgreSQL rights and restarted services. Moreover, you explored advanced tips for security and automation. Finally, you now have a working Odoo 18 instance ready for new databases.

For further reading, visit the official Odoo docs: https://www.odoo.com/documentation/18.0.


Discover more from teguhteja.id

Subscribe to get the latest posts sent to your email.

Tags:

1 thought on “Odoo database access denied”

  1. Pingback: Odoo 18 Access Permissions - teguhteja.id

Leave a Reply

WP Twitter Auto Publish Powered By : XYZScripts.com