【发布时间】:2020-06-16 15:44:38
【问题描述】:
我正在尝试将 Django 应用程序与 MySql docker 容器连接起来。我正在使用最新版本的 MySql 即 MySql 8.0 来构建容器。我能够成功构建 MySql 容器,但我无法使用 Django 的默认 MySql 连接器连接它。当我运行docker-compose up 命令时,我得到了下面提到的错误。
django.db.utils.OperationalError: (1045, 'Plugin caching_sha2_password could not be loaded: /usr/lib/x86_64-linux-gnu/mariadb19/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory')
我开始寻找解决方案,并了解到 MySql 在其默认身份验证插件中发布了一项重大更改,大多数 MySql 连接器都不支持该插件。
要解决此问题,我必须在 MySql 容器的 my.cnf 文件中将 default-authentication-plugin 设置为 mysql_native_password。
我使用命令docker exec -it <conatiner id> /bin/bash 登录到容器,并且还能够在容器内找到my.cnf 文件。
要编辑my.cnf 文件,我必须使用nano 命令,如下所述。
nano my.cnf
但不幸的是,MySql Container 中没有安装nano 命令。要安装nano,我需要在容器中安装sudo。
我尝试使用下面提到的命令安装sudo,但没有成功。
apt-get install sudo
错误-
Reading package lists... Done
Building dependency tree
Reading state information... Done
解决此问题的可能解决方案是什么。
【问题讨论】: