Delete Docker MySQL/MariaDB Database in a one-liner

I’ve been using the Bitnami MariaDB Docker Container when testing it with Ghost.

Rather than nuke-and-pave, starting over with the Database volume, just run a one-liner to delete the database as you go about testing:

  • The space that precedes the command is intended, for security.
  • Yes, not having a space after the -p parameter before providing the actual password is correct.

If you were to remove the IF EXISTS conditional, you’ll get a response from mysql:

docker exec --user root -t CONTAINER_ID_HERE /opt/bitnami/mariadb/bin/mysql -uroot -pPASSWORD_GOES_HERE -e 'DROP DATABASE bitnami_ghost;'

ERROR 1008 (HY000) at line 1: Can't drop database 'bitnami_ghost'; database doesn't exist

References

  • https://github.com/bitnami/bitnami-docker-mariadb
  • https://hub.docker.com/r/bitnami/mariadb/
  • https://www.liquidweb.com/kb/delete-a-mysql-database-on-linux-via-command-line/ +

This is a preview of Clap Button, a new feedback and analytics tools for Hydejack, built by yours truly. You can try it out on localhost for free, but it will be removed (together with this message) when building with JEKYLL_ENV=production. To use Clap Button on your site, get a subscription
and set clap_button: true in your config file.


© 2021. All rights reserved.