6

After getting the docker pull, if you proceed as follows, you will get a statement that it cannot be found.

I want to solve this problem.


docker pull mariadb
.
.
.
docker exec -it mariadb /bin/bash

mysql -u root -p

bash: mysql: command not found

I would like to know why the error occurred.

I want mysql to run.

next syntax

  • Enter Passoword
4
  • apt-get install vim I did.
    – baul kim
    Commented Jul 14, 2023 at 8:03
  • 2
    what does vim have to do with mysql? :) I hope you are not blindly running commands not understanding what they do? There are plenty of tutorials on how to get mysql running withing a docker image, or mariadb ... are you following any particular tutorial for this?
    – Ron
    Commented Jul 14, 2023 at 8:05
  • I followed the blog, but it was written as mysql on the blog, so I followed it exactly. I thought too much of a simple problem. thank you :)
    – baul kim
    Commented Jul 14, 2023 at 8:10
  • fckng mariadb!.. Commented Apr 3 at 8:11

3 Answers 3

12

This docker image has no mysql client installed by default. you can use mariadb -uroot -p

2
  • I followed the blog, but it was written as mysql on the blog, so I followed it exactly. I thought too much of a simple problem. thank you. :)
    – baul kim
    Commented Jul 14, 2023 at 8:10
  • @baulkim upvoute his answer! Commented Aug 17, 2023 at 19:18
7

As specified in MariaDB docker documentation, since mariadb:11 (mariadb:latest) has no mysql executable or symlink. mariadb is the official command line executable. Use of a mysql named executable will result in a deprecation warning.

https://mariadb.com/kb/en/mariadb-11-0-1-release-notes/#docker-official-images

To keep compatibility with existing scripts you can fix the docker image version number to a previous release that supports the mysql command, like mariadb:10.4

EDIT: To use the latest version (or any 10.5+ version) you should:

  • Rename calls to mysql command in any related script to mariadb,
  • Create a command alias in your script or ~/.bashrc file
    • alias mysql=/usr/bin/mariadb,
  • Add a line to the mariadb Dockerfile to create a 'wrapper' script
    • RUN echo '#!/bin/bash' > /usr/bin/mysql && echo 'mariadb "$@"' >> /usr/bin/mysql && chmod +x /usr/bin/mysql

Note: Creating a symbolic link from /usr/bin/mariadb to /usr/bin/mysql will trigger a warning from the command execution:

mysql: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb' instead

1
  • it is very bad feature! i try about hunderd times in container... that is not a fix Commented Apr 3 at 8:36
1

You can specify an older version that does have is:

mariadb:10.5

Or work round it like they suggest above.

It's annoying when you have builds / instructions using mariadb:latest and they changed it!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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