Django启动服务器时,报错mysql的2059错误的解决办法。

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weekdawn/article/details/81039382
版权说明:未经许可,不得转载

环境说明:
Windows 10
python 3.6.5
Django 2.0.5
mysql 8.0.11

当启动django自带的服务器时,报错2059:
> _mysql_exceptions.OperationalError: (2059, )

> django.db.utils.OperationalError: (2059, )

启动方式为如下:
> python manage.py runserver 0.0.0.0:8000

经过一番查询,调试,最终发现了问题所在。主要就是mysql8.0的问题。
目前最新的mysql8.0对用户密码的加密方式为caching_sha2_password, django暂时还不支持这种新增的加密方式。只需要将用户加密方式改为老的加密方式即可。

解决步骤:
1.登录mysql,连接用户为root。
> mysql -u root -p

2.执行命令查看加密方式
> use mysql;
> select user,plugin from user where user='root';

3.执行命令修改加密方式
> alter user 'root'@'localhost' identified with mysql_native_password by 'yourpassword'

4.属性权限使配置生效
> flush privileges



重设mysql8.0的加密方式后,再次启动django服务器就没有任何问题了。





-----------------------------------------@weekdawn--------------------------------------------------------
展开阅读全文
博主设置当前文章不允许评论。

mysql连接远端服务器时错误

12-01

当我在连接别人服务器上的mysql数据库的时候出现了错误,mysql数据库是别人的 别人给我开了个用户名和密码 不知道怎么了 我取connection的时候就报了这个错误rnrncom.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failurernrnThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.rn at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)rn at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)rn at java.lang.reflect.Constructor.newInstance(Unknown Source)rn at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)rn at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1118)rn at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:675)rn at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1078)rn at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2312)rn at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2122)rn at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:774)rn at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:49)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)rn at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)rn at java.lang.reflect.Constructor.newInstance(Unknown Source)rn at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)rn at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:375)rn at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:289)rn at java.sql.DriverManager.getConnection(Unknown Source)rn at java.sql.DriverManager.getConnection(Unknown Source)rn at com.fairytale.chat.db.DbUtil.getConnection(DbUtil.java:19)rn at com.fairytale.chat.db.DbUtil.main(DbUtil.java:107)rnCaused by: java.net.SocketException: Connection resetrn at java.net.SocketInputStream.read(Unknown Source)rn at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:114)rn at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:161)rn at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:189)rn at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2499)rn at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:599)rn ... 16 more 论坛

没有更多推荐了,返回首页