EC2 实例中 Ubuntu 20.04 上的 MySQL 客户端安装错误

Posted

技术标签:

【中文标题】EC2 实例中 Ubuntu 20.04 上的 MySQL 客户端安装错误【英文标题】:MySQL Client installation error on Ubuntu 20.04 in EC2 instance 【发布时间】:2021-06-22 05:02:35 【问题描述】:

使用缓存的mysqlclient-2.0.3.tar.gz (88 kB)

ERROR: Command errored out with exit status 1:
    command: /home/websiteuser/newenv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = 
'"'"'/tmp/pip-install-gtzius4s/mysqlclient_581cfbeeeb974b418354ec534fb82b74/setup.py'"'"';
 __file__='"'"'/tmp/pip-install-gtzius4s/mysqlclient_581cfbeeeb974b418354ec534fb82b74/setup.py'"'"'
;f=getattr(tokenize, '"'"'open'"'"', open)
(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-q2ahr_b3
        cwd: /tmp/pip-install-gtzius4s/mysqlclient_581cfbeeeb974b418354ec534fb82b74/
Complete output (15 lines):
/bin/sh: 1: mysql_config: not found
/bin/sh: 1: mariadb_config: not found
/bin/sh: 1: mysql_config: not found
Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-gtzius4s/mysqlclient_581cfbeeeb974b418354ec534fb82b74/setup.py", line 15, in <module>
    metadata, options = get_config()
    File "/tmp/pip-install-gtzius4s/mysqlclient_581cfbeeeb974b418354ec534fb82b74/setup_posix.py", line 70, in get_config
    libs = mysql_config("libs")
    File "/tmp/pip-install-gtzius4s/mysqlclient_581cfbeeeb974b418354ec534fb82b74/setup_posix.py", line 31, in mysql_config
    raise OSError(" not found".format(_mysql_config_path))
OSError: mysql_config not found
mysql_config --version
mariadb_config --version
mysql_config --libs
----------------------------------------

警告:丢弃https://files.pythonhosted.org/packages/3c/df/59cd2fa5e48d0804d213bdcb1acb4d08c403b61c7ff7ed4dd4a6a2deb3f7/mysqlclient-2.0.3.tar.gz#sha256=f6ebea7c008f155baeefe16c56cd3ee6239f7a5a9ae42396c2f1860f08a7c432(来自https://pypi.org/simple/mysqlclient/)(需要python:> = 3.5)。命令出错,退出状态为 1:python setup.py egg_info 检查日志以获取完整的命令输出。 错误:找不到满足要求的版本 mysqlclient==2.0.3 错误:没有找到 mysqlclient==2.0.3 的匹配分布

【问题讨论】:

【参考方案1】:

我已使用以下方法修复它:

sudo apt-get install python3-dev default-libmysqlclient-dev build-essential

然后:

pip install mysqlclient

这是 Ubuntu 的编译问题。

【讨论】:

以上是关于EC2 实例中 Ubuntu 20.04 上的 MySQL 客户端安装错误的主要内容,如果未能解决你的问题,请参考以下文章

将 phpMyAdmin 与 ec2 ubuntu 实例上的 ejabberd 服务器连接

从本地机器上的 ubuntu (AWS EC2) 读取文件?

更改 EC2 实例上的公共 DNS

socket_bind():无法绑定地址 [99](Amazon EC2 上的 Ubuntu)

为 EC2 上的 Ubuntu 16.04 解决关于 overcommit_memory 和透明大页面的 Redis 警告

ubuntu ec2-instance 上的 cloud-init 每次启动脚本