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?
相关问题
- sqlyog export query result as csv
- NOT DISTINCT query in mySQL
- MySQL: conduct a basic search
- Unable to run mariadb when mount volume
- Why sometimes there is one of more gap(s) in the v
This isn't too hard, but I think it's undocumented at this point, and definitely for advanced users. The root password for the MariaDB container is 'root', so you can
mysql -uroot -proot
in there, and you can also do it on the host. Assuming you have the mysql client on your host, you can do this:ddev describe
to get the mysql command and port number.mysql --host=127.0.0.1 --port=32841 --user=root --password=root
. Your port will be different.CREATE DATABASE newdb;
GRANT ALL ON newdb.* to 'db'@'%' IDENTIFIED BY 'db';
mysql --host=127.0.0.1 --port=32841 --user=root --password=root --database=newdb <dumpfile.sql
Alternately, you can use phpmyadmin (see the url in
ddev describe
) to do this but first you have to grant full privileges to the 'db' user that phpmyadmin uses, then the "Create" button in phpmyadmin will appear.See How can ddev automatically create additional databases? for how to automatically create an additional database for a project.