📝

[Django]You appear not to have the ‘mysql’

2021/05/02に公開

[課題] CommandError: You appear not to have the 'mysql' program installed or on your path. と出る

% python manage.py dbshell
CommandError: You appear not to have the 'mysql' program installed or on your path.

環境

  • Python
    • Dockerを使用してます。python:3.9-slim-buster
  • Django3.1

[原因] mysqlクライアントがない

エラーに吐かれている通りでmysqlクライアントがありません。whichでコマンドの所在を検索してもでません。

% mysql
bash: mysql: command not found
% which mysql

[解決策] mysqlクライアントを入れる

調べてみると、default-mysql-clientを入れれば良いっぽいので入れます。

Dockerを使っている人は、Dockerfileも書き換えると良いでしょう。

 % apt-get -y install default-mysql-client

Discussion