You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在ddev中导出数据库?解决ddev缺少export-db命令的问题

How to Export a Database in DDEV (Without export-db Command)

Hey there! Since DDEV doesn’t have a dedicated export-db command right now, don’t worry—there are several straightforward ways to dump your database. Here are my go-to methods:

1. Use ddev exec with Native mysqldump

You can run the standard mysqldump command directly inside the DDEV web container, and save the dump file to your project’s root directory (so it’s easily accessible on your host machine):

ddev exec "mysqldump -u db -pdb db > /var/www/html/db-dump.sql"
  • db is DDEV’s default database username, password, and database name—no need to change these unless you’ve customized your setup.
  • The exported db-dump.sql file will appear in your project’s root folder on your host.

2. Pipe Output Directly to a Host File

Skip the container file step entirely by piping the dump output straight to a file on your host:

# Export the full database
ddev mysqldump db > full-database-dump.sql

# Export specific tables only
ddev mysqldump db table_name_1 table_name_2 > specific-tables-dump.sql

ddev mysqldump is a wrapper that handles the container credentials automatically, so you don’t have to remember the username/password.

3. Export a Compressed Dump (For Large Databases)

If your database is large, save space by exporting a compressed file:

# Compress inside the container
ddev exec "mysqldump -u db -pdb db | gzip > /var/www/html/db-dump.sql.gz"

# Or compress directly on the host
ddev mysqldump db | gzip > full-database-dump.sql.gz

Quick Tip

If you need to export a database with a custom name (not the default db), just replace db in the commands above with your actual database name.

内容的提问来源于stack exchange,提问作者rfay

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:06:58