mariadbmysql-cli

Getting 'bash: mysql: command not found' error in docker


In docker container running mysql commands results in a

bash: mysql: command not found error

mysql --version, or any mysql command; same issue.

Adding mysql-client did not help. Suggestions about adding default-libmysqlclient-dev

apt-get install --no-install-recommends -y default-libmysqlclient-dev

Still no able to run mysql.


Solution

  • This helped.

    For newer MariaDB container versions, the mysql executable does not exist any more. Replace mysql with mariadb to fix the issue, for example:

    https://techoverflow.net/2023/07/13/how-to-fix-docker-mariadb-mysql-executable-file-not-found-in-path-unknown/

    All info online states mysql in command. For mariadb image it is maridb for any command eg.

    docker-compose exec -T mariadb mariadb -uroot -p
    

    Note for the client not installed, mariadb image has it

    using this to test:

    mariadb --version
    

    Shows client present

    mariadb from 11.3.2-MariaDB, client 15.2 for debian-linux-gnu (x86_64) using  EditLine wrapper