Database users, roles, and privileges
For Metabase to connect, query, and optionally write to your database, you need to create a dedicated database user with the appropriate privileges. This guide explains how to set up database users and roles following security best practices.Recommended setup
We recommend creating a dedicatedmetabase database user with read-only access to the schemas and tables you want to analyze.
Creating dedicated users and roles for Metabase makes it easier to manage permissions, audit usage, and troubleshoot issues without affecting other systems.
Role-based privilege structure
Organize privileges into roles based on use cases:Analytics role
Read-only access for querying and analysis
Transforms role
Write access to schema for transforms
Uploads role
Write access to schema for CSV uploads
Actions role
Write access to tables for actions and editable data
Model persistence role
Write access to schema for persisted models
Benefits of role-based permissions
Why use roles instead of direct user permissions?
Why use roles instead of direct user permissions?
Easier maintenance:
- Grant or revoke privileges by adding/removing roles
- No need to modify individual user permissions
- Use the same
analyticsrole for other BI tools - Share common privilege sets across multiple users
- Revoke write access for one feature without affecting others
- Example: Disable model persistence without affecting actions
- Clear separation between read and write operations
- Easier to audit who has which privileges
On Metabase Pro and Enterprise plans, use separate writeable connections for operations that require write access.
Minimum database privileges
To query your data in Metabase, the database user needs:- CONNECT privilege to your database
- SELECT privilege on schemas or tables you want to use
Setting up read-only access
Here’s how to create a properly configured read-only user (PostgreSQL example):- Step-by-step
- Complete script
Create analytics role and user
Follow these steps as a database administrator:1. Create an analytics roleQuery privilege options
Choose the appropriate privilege level based on your security requirements:Option 1: All data (PostgreSQL 14+)
Option 1: All data (PostgreSQL 14+)
Recommended for: Development environments, full analytics access
The
pg_read_all_data role is only available in PostgreSQL 14 or higher. See Predefined Roles in PostgreSQL documentation.Option 2: All schemas
Option 2: All schemas
Recommended for: Access to all schemas in a specific database
Option 3: Specific schema
Option 3: Specific schema
Recommended for: Production environments with isolated analytics schema
The
ALTER DEFAULT PRIVILEGES statement ensures that new tables automatically inherit the SELECT privilege.Option 4: Specific tables
Option 4: Specific tables
Recommended for: Maximum security with explicit table access
Additional optional privileges
Depending on your Metabase usage, you may also need:- Temporary tables
- Stored procedures
Grant all database privileges
For development or testing environments, you can give the Metabase user full access:Privileges to enable actions and editable table data
Both actions and editable table data allow Metabase to write data back to specific tables.- Overview
- Setup
When you need write access
Enable write access if you want to:- Create, update, or delete records through Metabase
- Use action buttons in dashboards
- Allow users to edit data directly in tables
Consider using a writeable connection (Pro/Enterprise) to separate read and write operations.
Privileges to enable model persistence
Model persistence saves query results to a dedicated schema in your database to improve performance.- Requirements
- Setup
- Best practices
What you need
- CREATE privilege on the database (to set up the schema)
- INSERT, UPDATE, DELETE privileges on the persistence schema
- A dedicated schema for storing persisted models
If you prefer not to grant CREATE privileges, manually create the schema before enabling model persistence.
Privileges to enable transforms
Transforms let Metabase write query results back to your database in dedicated tables.- Requirements
- Setup
What you need
- CREATE TABLE privilege on the transforms schema
- ALTER privilege to modify transform tables
- DROP privilege to remove old transforms
- Optionally, CREATE SCHEMA privilege
We strongly recommend creating a dedicated schema for transforms, separate from your source data.
Privileges to enable uploads
You can upload CSVs to supported databases for analysis in Metabase.- Requirements
- Setup
- Configure in Metabase
What you need
- A schema to store uploaded data
- INSERT, UPDATE, DELETE privileges on the uploads schema
- Configure the schema in Metabase settings
Create or designate a schema for uploads before configuring this feature in Metabase.
Multi-tenant permissions
For multi-tenant setups where customers need SQL access, create one database connection per customer.Why multi-tenant connections?
Why multi-tenant connections?
Security benefits:
- Each customer connects with their own database user
- Row-level security enforced at the database level
- Clear separation between customer data
- Grant access only to customer-specific schemas
- Different privilege levels per customer
- Easy to audit and revoke access
Example: Multi-tenant setup
Let’s say you have two customers: Tangerine and Lemon.- Benefits
- Best practices
Advantages of role-based multi-tenancy
Reusability:- Use
tangerine_queriesfor other analytics tools - Share common privileges across multiple connections
- Revoke
lemon_actionswithout affectinglemon_queries - Easy to add or remove specific capabilities
- Add new customers by creating new users and roles
- Update privileges by modifying roles, not individual users
- Each customer can only access their own schema
- Clear audit trail of who accessed what
Database-specific considerations
PostgreSQL
PostgreSQL
PostgreSQL-specific notes
Predefined roles (PostgreSQL 14+):pg_read_all_data: Read access to all tablespg_write_all_data: Write access to all tables
MySQL
MySQL
MySQL-specific notes
Grant syntax:- Use
'%'for any host - Use specific IP for production:
'metabase'@'192.168.1.100'
BigQuery
BigQuery
BigQuery-specific notes
BigQuery uses IAM roles instead of database users:Required roles:BigQuery Data ViewerBigQuery Metadata ViewerBigQuery Job User
- Create a service account in Google Cloud Console
- Download JSON key file
- Upload to Metabase
Snowflake
Snowflake
Snowflake-specific notes
Role hierarchy:Verifying privileges
After setting up privileges, verify the Metabase user has correct access:- PostgreSQL
- MySQL
- Test connection
Security best practices
Use strong passwords
Generate long, random passwords for database users
Principle of least privilege
Only grant the minimum necessary permissions
Separate read and write
Use different users for read-only and write operations
Regular audits
Periodically review and update user privileges
Use SSL connections
Always encrypt database connections in production
Restrict network access
Use firewall rules to limit database access
Monitor access
Log and review database access patterns
Rotate credentials
Regularly update passwords and service account keys
Further reading
Writeable connections
Separate write operations from read operations (Pro/Enterprise)
Permissions strategies
Learn permission strategies for your organization
Permissions introduction
Overview of Metabase permissions
People overview
Managing users and groups in Metabase