I’m trying to export a database from a DDEV project, however running into various problems.
I’ve tried ddev poweroff
and starting the one project.
Option 1 - Method one phpMyAdmin
Using Export > Quick Method.
A .sql file is produced but only has insert statements (missing create table statements, this is strange as it’s been working up until now.)
Option 2 - Using mysqldump on the command line:
ddev mysqldump -udb -pdb -x -A > /Users/me/dbs.sql;
This produces a dbs.sql file however has the following error:
mysqldump: Couldn't execute 'FLUSH /*!40101 LOCAL */ TABLES': Access denied;
you need (at least one of) the RELOAD privilege(s) for this operation (1227)
Failed to execute command mysqldump -udb -pdb -x -A: exit status 2
Option 3 - ddev export-db Just get a screen full of nonsense (see below) and no .sql file. DDEV logs does not seem to give any clues.
Any help would be appreciated.
ddev export-db
creates gzipped output by default, so that's why you're seeing binary output. ddev help export-db
will show you examples of what to do, for example:
ddev export-db --file=/tmp/db.sql.gz'
ddev export-db -f /tmp/db.sql.gz
ddev export-db --gzip=false --file /tmp/db.sql
ddev export-db > /tmp/db.sql.gz
ddev export-db --gzip=false > /tmp/db.sql
ddev export-db myproject --gzip=false --file=/tmp/myproject.sql
ddev export-db someproject --gzip=false --file=/tmp/someproject.sql
So start out by doing teh first example, `ddev export-db --file=/tmp/db/sql.gz and you'll be well on your way. Go ahead and try out the other examples if they're better for you.
There are many other ways to work with databases in ddev, but for your use ddev export-db
is the most obvious and easiest. For an article explaining all the different things you can do, see DDEV-Local Database Management or the DDEV-Local docs.