Contents of articles
Solutions for error reporting
abstract
Pymysql connect to MySQL reported an error of keyerror255. Recently, I was trapped for more than two months by a difficult problem. If you search this title, you can see that the search engine has provided n ^ 2 articles on solutions. Why do you still trap me for so long?Don’t I know Baidu?NO NO NO!! The biggest problem is that my executive computer and data storage computer are not the same computer!!
Error information
File "D:\Programfiles\Anaconda3\lib\site-packages\pymysql\connections.py", line 1269, in _get_server_information
self.server_charset = charset_by_id(lang).name
File "D:\Programfiles\Anaconda3\lib\site-packages\pymysql\charset.py", line 38, in by_id
return self._by_id[id]
KeyError: 255
The main reason is that MySQL 8.0 updates many character sets, but these character sets are longer than 255 code>, so the old version of pymysql does not support characters longer than 255
Online can find a lot of articles to solve this problem, consistent solution, update pymysql
pip install --upgrade pymysql
The following casually put a, interested can see, don't look also doesn't matter, full text summary on a sentence update pymysql, directly execute the above update code, if solve, OK! All is well, you can quit, but you can't solve it. The link article is not meaningful. Let's continue to read my text
Django appears after changing the default database SQLite3 to pymsql Keyerror:255 How to upgrade pymysql
Solution
As mentioned before, my executive computer and data storage computer are not the same computer!!
My own computer is mysql5.7, and the data storage computer version is 8.1
because at the beginning, the company's network security was upgraded to a secondary level, and then the company's intranet VPN was updated once (big exchange, the interface is different),
so at the beginning, I thought it was caused by the network security policy,
after all, all the online updates are pymysql, I'm already up-to-date and can't update any more
In fact, the solution is in a word, too lazy to beat around the bush so many words
uninstall and reload MySQL code>
yes! You're right! Is the MySQL database to unload, and then re install a version of 8.0 and above
So the main reason is that at the beginning MySQL 8.0 has updated many character sets, but the length of these character sets exceeds 255 code>
Write in the last canvassing session
recently participated in the CSDN official organization of"geek +" original blogger competition code>
after many screening, finally on the top 50
original is not easy, help cast a free vote
support: Click to vote
thank you!!!
Read More:
- An error 1064 is reported when pymysql accesses the image
- An error was reported during MySQL 6.0 installation: start service failed
- An error was reported in the process of importing the table from mysql5.7: [err] 1067 – invalid default value for ‘***‘
- An error was reported when idea compiles Java: no symbol was found_ How to solve this problem
- Python reported an error with keyerror: ‘longitude’
- An error is reported when the jeecg boot project connects to the MySQL database running on docker
- An error occurs when pymysql uses% d to pass in parameters
- “No nodes available to run query” is reported when using Presto to connect to MySQL query“
- [error handling] when logging into MySQL with CentOS command, an error 1045 (28000) is reported
- Zeppelin uses spark to connect to MySQL and reports an error
- MySQL: if the remote connection using navicatip fails, prompt “is not allowed to connect to this MySQL server”
- Pikachu vulnerability is installed in the shooting range, and an error is reported when connecting to the MySQL database
- An error is reported when kettle connects Oracle database and MySQL database
- The MySQL service suddenly hangs up with the error message can’t connect to MySQL server on ‘localhost’ (10061)
- An error was reported when springboot connected to redis Servlet.service () for servlet [dispatcherServlet] in context with path [] threw e
- PHP connection to MySQL database error: call to undefined function MySQL_ connect()
- It can’t connect to local MySQL server through socket ‘/ tmp/ mysql.sock ‘(2) “;
- MySQL Workbench Failed to Connect to MySQL at 127.0.0.1:3306 with user root Bad handshake
- An error was reported during PSU upgrade: OPatch failed with error code 73
- Ntpdate reported an error when updating the clock, and the problem of no server suitable for synchronization found was solved