PhpStorm (and all JetBrains tools) have a nice database browser:.ddev describe tells you the URL for the built-in phpMyAdmin database browser (Hint: It’s.However, it’s gotten little love in recent years, so DDEV now supports TablePlus and SequelAce if they’re installed. macOS users love ddev sequelpro, which launches the free Sequelpro database browser.I like to ddev ssh (into the web container) and then mkdir /var/or mysqldump db | gzip >/var/(Because /var/Other database explorers: There are lots of alternatives for GUI database explorers: Mysqldump: The web and db containers also have mysqldump so you can use it any way you want inside there. MySQL client in containers: Both the web and db containers have the mysql client all set up and configured, so you can run ddev ssh or ddev ssh -s db and then use mysql however you choose to. You can also do things like echo "SHOW TABLES " | ddev mysql or `ddev mysql -uroot -proot` to get root privileges. I might run ddev mysql and give an interactive command like DROP DATABASE backend. I like to use it for lots of things because I like the command line. Then if you want to delete everything with ddev delete -O (omitting the snapshot since we have one already), and then ddev start again, we can ddev restore-snapshot two-dbs and we’ll be right back where we were.ĭdev mysql: ddev mysql gives you direct access to the MySQL client in the db container. It includes the entire state of the db server, so in the case of our two databases above, both databases and the system level “mysql” database will all be snapshotted. I like to name my snapshots so I can find them later, so ddev snapshot -name=two-dbs would make a snapshot named “two-dbs” in the. It’s great for when you’re working incrementally on migrations or updates and want to save state so you can start right back where you were. ddev export-db -target-db=backend -f will dump the database named “backend”.ĭatabase snapshots: With snapshots you can easily save the entire status of all of your databases. For example, ddev import-db -target-db=backend -src= will create the database named “backend” with permissions for that same “db” user and import from the dumpfile.Įxporting extra databases: You can export in the same way: ddev export-db -f will export your default database (“db”). Note that if you want to change database type, especially to downgrade, you need to export your database and then ddev delete the project (to kill off the existing database), make the change to a new db type, start again, and import.ĭefault database: DDEV creates a default database named “db” and default permissions for the “db” user with password “db”, and it’s on the (inside Docker) hostname “db”.Įxtra databases: In DDEV v1.13+ you can easily create and populate other databases as well. Many database backends: You can use a vast array of different database types, including MariaDB from 5.5 through 10.4 and MySQL from 5.5 through 8.0 ( docs). Remember, you can run ddev -help for more info on many of the topics below. Most people know about ddev import-db and ddev export-db but those tools now have more flexibility and there are plenty of other adaptable ways to work with your databases. DDEV provides lots and lots of flexibility for you in managing your databases between your local development, staging and production environments.
0 Comments
Leave a Reply. |