Search code examples
databaseddev

DDEV is there a command to (re-)create an empty database?


I've dropped the default database db and was not able to restart DDEV anymore and got some errors about not-existing DB.

Used ddev delete to re-start.

Is there a command that just created default DB?


Solution

  • First, ddev delete or ddev delete --omit-snapshot is the normal way to delete the db database.

    Second, if you did want to delete the default db database some other way, you could use ddev mysql. For example,

    ddev exec -s db 'mysql --database=mysql -e "CREATE DATABASE db;"'

    But mostly... don't delete the default database. Maybe you can explain why you'd want to do that. If you want to drop all tables in the database there are better ways to do that.