Mautic数据库架构分析:本地部署后数据存储位置及方式咨询
Hey there! Let's break down Mautic's data storage mechanism since you've got it running locally. I've worked with Mautic's backend a fair bit, so here's what you need to know:
Mautic is a classic LAMP/LEMP stack application, meaning its core structured data lives in a relational database (mostly MySQL/MariaDB), while unstructured assets and temporary files are stored directly on your local filesystem.
1. Database (DB) Storage Details
1.1 Database Schema Structure
Mautic uses Doctrine ORM to manage its database, so the schema is defined via PHP entity classes—but once installed locally, you can inspect the actual tables directly in your database. Here are the most critical tables tied to user-entered data:
leads: Stores core contact/lead data (names, emails, phone numbers, default fields)lead_fields: Defines custom contact fields you create in the Mautic backendlead_field_values: Stores values for custom contact fields (links toleadsandlead_fieldstables)assets: Metadata for uploaded files (images, PDFs, docs) — the actual file lives on your filesystememails: Email templates, draft emails, and send logscampaigns: Configuration data for your marketing campaignslead_visits: Tracks visitor behavior on your tracked pages
To inspect the schema locally, you can use tools like phpMyAdmin, or run these MySQL commands in your terminal:
# Log into your MySQL server (replace placeholders with your credentials) mysql -u your_db_username -p your_mautic_db_name # List all Mautic tables SHOW TABLES; # View the structure of a specific table (e.g., the leads table) DESCRIBE leads;
1.2 Database File Location
If you're using a local MySQL/MariaDB instance, the physical database files are stored in these default paths:
- Linux:
/var/lib/mysql/your_mautic_db_name/(each table has corresponding.frmand.ibdfiles for InnoDB engine) - Windows:
C:\ProgramData\MySQL\MySQL Server X.X\Data\your_mautic_db_name\ - macOS (Homebrew-installed MySQL):
/usr/local/var/mysql/your_mautic_db_name/
2. Local Filesystem Storage
Mautic stores non-structured data directly in its installation directory. Key paths to note:
media/files/: Stores all uploaded assets (images, PDFs, documents) — each file maps to a record in theassetsdatabase tablemedia/images/: Hosts images used in emails, landing pages, and system-generated assets like QR codesmedia/cache/: Temporary cache files (compiled templates, image thumbnails, etc.) — safe to delete if you need to clear cacheapp/config/local.php: Contains your database connection credentials (username, password, database name) — you can verify which database Mautic is connected to here
3. Data Flow Example: When You Enter a Contact
Let’s walk through what happens when you add a new contact in Mautic:
- You submit the contact form in the Mautic backend
- Mautic uses Doctrine ORM to write the default field data (name, email) to the
leadstable - If you used custom fields, their values are stored in the
lead_field_valuestable, linked to the contact’s ID inleads - If you upload an avatar for the contact, the image file is saved to
media/files/, and its metadata (file path, size) is added to theassetstable, with a link back to the contact’sleadsrecord
内容的提问来源于stack exchange,提问作者greeshma y

