phpMyAdmin and MariaDB with Docker

I used to run a MariaDB server on an old Linux machine for working with database dumps and other things, but after moving all of that to a new Raspberry Pi 4, I never really set it back up.

So instead I thought I’d play with this fancy new Docker stuff all the cool kids are talking about. I ended up getting phpMyAdmin and MariaDB working with Docker on my MacBook Pro.

Caveat:

To start up the MariaDB container thing, I ran this command:

docker run -d \
 -v $HOME:/home/hosthome \
 --name mariadb \
 -e MYSQL_ROOT_PASSWORD=hunter2 \
 -e MYSQL_DATABASE='default_db' \
 mariadbCode language: JavaScript (javascript)

A few things here you might want to make note of:

  • hunter2 – My MariaDB root password.
  • default_db – The default database created, just to make things easy.
  • $HOME – This attached my local machine’s home directory to the MariaDB container so I can import/export files.

Secondly, I ran this to start phpMyAdmin and connect it to the Docker container:

docker run -d \
 --name phpmyadmin \
 --link mariadb:db \
 -p 8081:80 \
 -e UPLOAD_LIMIT='4096M' \
 phpmyadmin/phpmyadminCode language: JavaScript (javascript)

A few things here you might want to make note of:

  • 8081 – This is the local machine port that I will connect to via HTTP
  • 4096M – The default upload limit, set to 4 Gigs.

Now, once this done, you should be able to connect to phpMyAdmin via http://localhost:8081/ and do all sorts of terrible things.

Here’s a few more commands that may come in handy:

Start a shell in the MariaDB container: docker exec -it mariadb bash

Import a SQL file: docker exec -i mariadb sh -c 'exec mysql -uroot -phunter2 default_db' < /some/path/on/your/host/all-databases.sql

Start a MariaDB “mysql” shell: docker exec -it mariadb sh -c 'exec mysql -uroot -phunter2 default_db'

References that helped me:

Other Posts Not Worth Reading

Hey, You!

Like this kind of garbage? Subscribe for more! I post like once a month or so, unless I found something interesting to write about.


Comments

Leave a Reply