如何从ddev导出数据库? [英] How can I export a database from ddev?

查看:115
本文介绍了如何从ddev导出数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ddev当前缺少export-db命令(请参见 https://github.com/drud / ddev / issues / 767

ddev currently lacks an export-db command (see https://github.com/drud/ddev/issues/767)

如何导出数据库?

推荐答案

从ddev v1.4.0(2018-11-14)开始,有一个 ddev export-db 命令。您可以执行以下操作(来自 ddev export-db -h ):

As of ddev v1.4.0 (2018-11-14), there is a ddev export-db command. You can do these things (from ddev export-db -h):

ddev export-db >/tmp/db.sql.gz
ddev export-db --gzip=false >/tmp/db.sql
ddev export-db -f /tmp/db.sql.gz

此外,不要忘记 ddev快照,这是快速转储数据库的好方法,但它不如基于文本的转储可移植。 (请参阅 ddev快照-h ddev restore-snapshot -h 。)

In addition, don't forget about ddev snapshot, which is a great and quick way to make a quick dump of your db, but it's not as portable as a text-based dump. (See ddev snapshot -h and ddev restore-snapshot -h.)

使用容器内技术的原始答案:
我总是这样做:

Original answer with in-container techniques: What I always do is this:

ddev ssh
mkdir /var/www/html/.tarballs
mysqldump db | gzip >/var/www/html/.tarballs/db.sql.gz
# or with explicit authentication
mysqldump -udb -pdb -hdb db | gzip >/var/www/html/.tarballs/db.sql.gz

或用于Drupal / drush用户:

or for Drupal/drush users:

ddev ssh
drush sql-dump --gzip >.tarballs/my-project-db.sql.gz

这会将转储文件放置在项目的.tarballs目录中,以备后用(位于主机)。

That places the dump in the project's .tarballs directory for later use (it's on the host).

但是,我很期待导出数据库命令到达此处。

However, I'm looking forward to the export-db command when it gets here.

请注意,从v1.1.0开始,您可以使用 ddev snapshot 命令将数据库副本保存在.ddev / db_snapshots目录中。这不是.sql.gz文本文件,而是保存好的数据库。

Note also that starting with v1.1.0 you can use the ddev snapshot command to save a copy of a database in the .ddev/db_snapshots directory. It's not a text .sql.gz file, but it's a good saved db.

这篇关于如何从ddev导出数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆