I have a Drupal multisite that needs to have one database for each site, and want it to run in ddev, but ddev just has the one database by default, named 'db'. How can I get a second database?
You can import additional databases directly with ddev import-db --database=newdb
--file=/path/to/file.sql.gz. The created database will already have permissions, etc.
You can also manually create and manage databases (although this is rarely necessary). The root password for the db server is 'root', so you can mysql -uroot -proot
in there (or use ddev mysql -uroot -proot
).
ddev mysql -uroot -proot
CREATE DATABASE newdb;
GRANT ALL ON newdb.* to 'db'@'%' IDENTIFIED BY 'db';
ddev import-db --database=newdb --file=dumpfile.sql
More details about database management at https://ddev.readthedocs.io/en/stable/users/usage/database-management/