Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.2k views
Welcome To Ask or Share your Answers For Others

1 Answer

Updated 2020-06-02: In recent versions of ddev, you can import additional databases directly with ddev import-db --target-db=newdb. The created database will already have permissions, etc.

The rest of the answer has been edited to bring it up to date...

You can also manually create and manage databases (although this is rarely necessary any more). 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';
  • Now, if you want to load from a db dump, ddev import-db --target-db=newdb --src=dumpfile.sql
  • Your normal web user can now access this alternate db, and it can be used in the settings.php for your alternate multisite.
  • There are many other things you'll want to do for your Drupal multisite; there is a full tutorial at https://github.com/drud/ddev-contrib/tree/master/recipes/drupal8-multisite

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...