How do I send an SQL command the the database docker image?

I use nextcloud in docker, so I have two docker images, the app and the database docker image.

How do I send an SQL command directly to the database and get the result on the bash console?

Do I have to write a new extra nextcloud module to achieve this?

more or less like this. “{” means this is optional, with --user your are root “}”

docker exec {--user my-be-a-database-user} docker-name-of-your-db-container mysql .....

This works:

docker exec nextcloud_db_1 mysql nextcloud -p$yourMysqlRootPassword -e "select * from oc_activity limit 10"
1 Like