Django執(zhí)行python?manage.py?makemigrations報錯的解決方案分享
1.環(huán)境
mysql 8.0
Django 3.2
pycharm 2021.11
2. (No changes detected)及解決
2.1 問題情景
# 遷移數(shù)據(jù)庫 python manage.py makemigrations python manage.py migrate
報錯
RuntimeWarning: Got an error checking a consistent migration history performed
for database connection 'default': (2059, <NULL>)
warnings.warn
(No changes detected)
2.2 原因分析
MySQL 8.x加密方式:caching_sha2_password
MySQL 5.x加密方式為:mysql_native_password
所以要改成mysql_native_password
2.3 修改方式
由cmd進入命令行
登錄到mysql: mysql -u username -p password
參數(shù)說明:[-u]后面接的是登錄數(shù)據(jù)庫的賬號,[-p]后面是密碼
如果無法登錄,可能的原因是環(huán)境變量中PATH變量沒有加入MySQL的目錄,可以添加環(huán)境變量或在開始菜單中找到MySQL 8.0 Command Line Client
進行登錄(這種方式打開后直接輸入密碼即可)。
查看你的賬號加密方式
use mysql select user,plugin from user
mysql> use mysql Database changed mysql> select user,plugin from user; +------------------+-----------------------+ | user | plugin | +------------------+-----------------------+ | cyk | caching_sha2_password | | mysql.infoschema | caching_sha2_password | | mysql.session | caching_sha2_password | | mysql.sys | caching_sha2_password | | root | caching_sha2_password | +------------------+-----------------------+
輸入下面的指令進行修改
mysql> alter user '用戶名'@'localhost' identified with mysql_native_password by '你的密碼';
再次查看
mysql> select user,plugin from user; +------------------+-----------------------+ | user | plugin | +------------------+-----------------------+ | cyk | caching_sha2_password | | mysql.infoschema | caching_sha2_password | | mysql.session | caching_sha2_password | | mysql.sys | caching_sha2_password | | root | mysql_native_password | +------------------+-----------------------+
3. (2026, ‘SSL connection error:unknown error number‘) 及解決
3.1 問題情景
# 遷移數(shù)據(jù)庫 python manage.py makemigrations python manage.py migrate
報錯Windows下django.db.utils.OperationalError: (2026, ‘SSL connection error: unknown error number‘)
3.2 原因分析
較高版本的mysql的ssl默認是開啟的
3.3 解決方案
關(guān)閉ssl
登錄mysql之后,輸入該命令:
mysql> SHOW VARIABLES LIKE '%ssl%';
修改配置文件my.ini(可能要通過屬性修改權(quán)限,否則無法修改成功)
# 路徑:C:\ProgramData\MySQL\MySQL Server 8.0 [mysqld] skip_ssl # 忽略ssl
重啟mysql服務(wù)重新執(zhí)行命令
mysql> SHOW VARIABLES LIKE '%ssl%';
總結(jié)
到此這篇關(guān)于Django執(zhí)行python manage.py makemigrations報錯解決的文章就介紹到這了,更多相關(guān)執(zhí)行python manage.py makemigrations報錯內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Python如何讀寫二進制數(shù)組數(shù)據(jù)
這篇文章主要介紹了Python如何讀寫二進制數(shù)組數(shù)據(jù),文中講解非常細致,代碼幫助大家更好的理解和學(xué)習(xí),感興趣的朋友可以了解下2020-08-08Python cookbook(數(shù)據(jù)結(jié)構(gòu)與算法)同時對數(shù)據(jù)做轉(zhuǎn)換和換算處理操作示例
這篇文章主要介紹了Python cookbook(數(shù)據(jù)結(jié)構(gòu)與算法)同時對數(shù)據(jù)做轉(zhuǎn)換和換算處理操作,涉及Python使用生成器表達式進行數(shù)據(jù)處理的相關(guān)操作技巧,需要的朋友可以參考下2018-03-03哪種Python框架適合你?簡單介紹幾種主流Python框架
這篇文章主要介紹了幾種主流的Python框架,幫助大家更好的理解和學(xué)習(xí)Python,感興趣的朋友可以了解下2020-08-08