阅读:49
我是一个甜甜的大橙子🍊,欢迎关注✉️!
我相信技术的力量💪
努力将所学分享给大家😎
你的点赞❤️分享🚀收藏📖就是对我最大的鼓励!
mysql 8.0
Django 3.2
pycharm 2021.11
# 迁移数据库
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)
MySQL 8.x加密方式:caching_sha2_password
MySQL 5.x加密方式为:mysql_native_password
所以要改成mysql_native_password
由cmd进入命令行
登录到mysql: mysql -u username -p password
参数说明:[-u]后面接的是登录数据库的账号,[-p]后面是密码
如果无法登录,可能的原因是环境变量中PATH变量没有加入MySQL的目录,可以添加环境变量或在开始菜单中找到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 |
+------------------+-----------------------+
# 迁移数据库
python manage.py makemigrations
python manage.py migrate
报错
Windows下django.db.utils.OperationalError: (2026, ‘SSL connection error: unknown error number‘)
较高版本的mysql的ssl默认是开启的
关闭ssl
mysql> SHOW VARIABLES LIKE '%ssl%';
# 路径:C:\ProgramData\MySQL\MySQL Server 8.0
[mysqld]
skip_ssl # 忽略ssl
mysql> SHOW VARIABLES LIKE '%ssl%';