Django连接mysql常见错误

  • 1045, “Access denied for user 'root'@'localhost' (using password: YES)”
    数据库的密码或用户名不对,查看settings.py

  • 1049, "Unknown database 'nav_db'"
    数据库不存在,查看settings.py或在mysql中新建数据库

  • RuntimeError: Model class django_openid_auth.models.Nonce doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
    在INSTALLED_APPS中卸掉一个模块后,urls.py的urlpatterns也要卸掉对应的路由

  • 1146, "Table 'nav_db.django_session' doesn't exist"
    需要先初始化django的数据表

python manage.py makemigrations
python manage.py migrate

  • 1251, 'Client does not support authentication protocol requested by server; consider upgrading MySQL client'
    需要在mysql客户端重置密码
>>USE mysql; 
>>ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '831015';
>>FLUSH PRIVILEGES;

  • python2.7无法安装MySQLDB或者mysqlclient
    下载一个mysqlclient-1.4.2-cp27-cp27m-win_amd64.whl,pip install
原文地址:https://www.cnblogs.com/luozx207/p/10477103.html