Aqua-Dream / Tieba_Spider

百度贴吧爬虫(基于scrapy和mysql)
404 stars 116 forks source link

mysql 插入错误 #4

Closed ZORQBPJHz closed 6 years ago

ZORQBPJHz commented 6 years ago

2018-06-11 11:14:58 [tieba] ERROR: Insert to database error: [Failure instance: Traceback: <class '_mysql_exceptions.OperationalError'>: (2019, "Can't initialize character set utf8mb4 (path: C:\mysql\\share\charsets\)") c:\python\anaconda\lib\threading.py:801:bootstrap_inner c:\python\anaconda\lib\threading.py:754:run c:\python\anaconda\lib\site-packages\twisted_threads_threadworker.py:46:work c:\python\anaconda\lib\site-packages\twisted_threads_team.py:190:doWork --- --- c:\python\anaconda\lib\site-packages\twisted\python\threadpool.py:250:inContext c:\python\anaconda\lib\site-packages\twisted\python\threadpool.py:266: c:\python\anaconda\lib\site-packages\twisted\python\context.py:122:callWithContext c:\python\anaconda\lib\site-packages\twisted\python\context.py:85:callWithContext c:\python\anaconda\lib\site-packages\twisted\enterprise\adbapi.py:464:_runInteraction c:\python\anaconda\lib\site-packages\twisted\enterprise\adbapi.py:36:init c:\python\anaconda\lib\site-packages\twisted\enterprise\adbapi.py:76:reconnect c:\python\anaconda\lib\site-packages\twisted\enterprise\adbapi.py:431:connect c:\python\anaconda\lib\site-packages\MySQLdb\init.py:81:Connect c:\python\anaconda\lib\site-packages\MySQLdb\connections.py:221:init__ c:\python\anaconda\lib\site-packages\MySQLdb\connections.py:312:set_character_set ] when dealing with item: {'author': u'\u5706\u53c8\u5706_00', 'content': u'\u4e13\u4e1a\u7b5b\u67e5\u662f\u4ec0\u4e48\uff1f', 'id': u'89618631379', 'post_id': u'10404126902', 'time': '2016-05-14 11:09:24'}

pip show MySQL-python Name: MySQL-python Version: 1.2.5 Summary: Python interface to MySQL Home-page: https://github.com/farcepest/MySQLdb1 Author: Andy Dustman Author-email: farcepest@gmail.com License: GPL Location: c:\python\anaconda\lib\site-packages Requires: Required-by:

mysql8.0

pettersoderlund commented 6 years ago

Hi, I've had this problem before. I think it is a windows / mysql issue with charsets.. Unfortunately i dont remember how i solved it... I think it had to do with settings of the mysql service.

Aqua-Dream commented 6 years ago

I think the reason is that mysql-python has not been updated for many years. Please try mysqlclient.

pip uninstall mysql-python
pip install mysqlclient

As for windows, see Django安装mysqlclient.

ZORQBPJHz commented 6 years ago

it works ,thanks @Aqua-Dream