As far as I know, DDEV provides configuration options for phpMyAdmin to comfortably work with containered MySQL/MariaDB databases. But I would rather like to use a different tool like e.g. phpStorm or DBeaver or such. Is there a way to make my wish come true?
Supplementing the docker-compose configuration I exposed port 3306, accordingly.
version: '3.6'
services:
web:
ports:
- 3306:3306
Trying to connect to a containered MariaDB database from my client host looks like the following.
$ mariadb --host=foo.ddev.site --user=db --password=db --database=db
ERROR 2013 (HY000): Lost connection to MySQL server at 'handshake: reading initial communication packet', system error: 11
The database port is already exposed in ddev, so can easily be used with many, many external tools.
For example, ddev mysql
gives you direct access, and there are also ddev sequelpro
and ddev sequelace
and ddev tableplus
, and there's an example in the custom commands showing how to do it with mysqlworkbench (See ~/.ddev/commands/host/mysqlworkbench.example).
Many other database browsers have direct support, see https://ddev.readthedocs.io/en/stable/users/usage/database-management/#database-guis
All of those grab the already-exposed db port.
ddev describe
on any project tells you how to access the port.
The host_db_port
setting in your project's .ddev/config.yaml can be used to lock down the exposed port so you can easily use it with PhpStorm.
This article also goes through some of the many ways you can access the database using ddev, https://ddev.com/blog/ddev-local-database-management/