1

I installed a new wordpress project using docker's guide:

mkdir my-wordpress-site
cd my-wordpress-site
ddev config --project-type=php
ddev composer create wordpress/skeleton --no-interaction --prefer-dist
ddev config --docroot=wp --project-type=wordpress
ddev restart

All done and I ran the front-end configuration.

I am used to running things in windows(xampp) and heard of MAMP for mac. but now I need to use docker and have no clue of how to go about things.

Question is: Is there a way I can access my database using Docker? ssh or anything?

4

There are ever-so-many ways to access the database. ddev describe will open your eyes to them.

  • As @Andy Mardell points out, you can use the built-in PHPMyAdmin (link in ddev describe)
  • You can also use a mysql client on the host, the port and such for this are also shown in ddev describe
  • You can also use ddev mysql for direct access to the database (ddev v1.10+)
  • On macOS, you can use ddev sequelpro if you have the excellent, free SequelPro installed.
  • You can also ssh into either the web container or the db container, ddev ssh or ddev ssh -s db and use the mysql client there.
  • You can also use ddev exec mysql, which is really pretty much the same as ddev mysql

I hope that's enough ways! :)

3

PhpMyAdmin

phpMyAdmin is installed with the commands you ran.

It seems to generate a random port. So do the following:

docker ps

You should see a line which is called drud/phpmyadmin. Look along the table and you should see the port it's running on. In my case, this was 0.0.0.0:32773->80/tcp

So if I go to http://localhost:32773 I see phpmyadmin, where you can access and edit your database.

PhpMyAdmin is fine to start, but you might want to use a database client to remotely access the database long term:

Remote access

If you want to use a database client to connect to your database, there is a similar process. Find out what port your database image is exposing:

ps docker

See the line called drud/ddev-dbserver? What port is this using? In my case it was 127.0.0.1:32782->3306/tcp.

So to connect to this database I can use port 32782. Again, in my case the details to connect were:

Host: 127.0.0.1 Database: db User: db Password: db Port: 32782

Hope that helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.