博主在Kali Linux下面使用PyCharm开发Django项目的时候需要连接数据库,然而出现报错
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 1.3.10.
意思大概是Django需要更高版本的mysqlclient才行,我机器自带的版本过低,那么升级一下就OK了
执行pip的升级命令
sudo -H pip3 install -U mysqlclient
然而报错
OSError: mysql_config not found
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-ngjxo2y1/mysqlclient/
这个报错有点熟悉,我之前博文有遇到过,这里因该是缺少libmysqlclient的包,但是我使用apt search 却没有搜索到 libmysqlclient的软件包,倒是找到了 libmariadbclient 的包,直接安装
sudo apt-get install libmariadbclient-dev -y
然后再次执行升级操作
sudo -H pip3 install -U mysqlclient
顺利安装,然而在连接数据库的时候再次报错了,这次的错误就有点奇怪了
django.db.utils.OperationalError: (2000, 'Unknown MySQL error')
看起来像是Mysql的问题,难道是不允许连接或者是账号密码错误?直接使用终端连接看看
mysql -h 192.168.88.88 -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 4604
Server version: 5.7.27-log MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]>
终端连接一切正常,这就有意思了,得想办法解决这个问题。
» 阅读全文