MySQLdb._exceptions.OperationalError
来源:4-19 pipeline数据库保存
慕娘7402538
2020-04-04
老师您好,入库的时候报错这一行self.conn = MySQLdb.connect(‘127.0.0.1’, ‘root’, ‘root’, ‘article_spider’, charset=“utf8”, use_unicode=True)原因是MySQLdb._exceptions.OperationalError: (1045, “Access denied for user ‘root’@‘localhost’ (using password: YES)”),我安装了mysql8.0,是不是版本的问题
整个报错:
2020-04-04 21:30:04 [twisted] CRITICAL:
Traceback (most recent call last):
File “C:\Users\Mr JIE\AppData\Local\Programs\Python\Python37\lib\site-packages\twisted\internet\defer.py”, line 1418, in _inlineCallbacks
result = g.send(result)
File “C:\Users\Mr JIE\AppData\Local\Programs\Python\Python37\lib\site-packages\scrapy\crawler.py”, line 89, in crawl
self.engine = self._create_engine()
File “C:\Users\Mr JIE\AppData\Local\Programs\Python\Python37\lib\site-packages\scrapy\crawler.py”, line 103, in _create_engine
return ExecutionEngine(self, lambda : self.stop())
File “C:\Users\Mr JIE\AppData\Local\Programs\Python\Python37\lib\site-packages\scrapy\core\engine.py”, line 70, in init
self.scraper = Scraper(crawler)
File “C:\Users\Mr JIE\AppData\Local\Programs\Python\Python37\lib\site-packages\scrapy\core\scraper.py”, line 71, in init
self.itemproc = itemproc_cls.from_crawler(crawler)
File “C:\Users\Mr JIE\AppData\Local\Programs\Python\Python37\lib\site-packages\scrapy\middleware.py”, line 53, in from_crawler
return cls.from_settings(crawler.settings, crawler)
File “C:\Users\Mr JIE\AppData\Local\Programs\Python\Python37\lib\site-packages\scrapy\middleware.py”, line 35, in from_settings
mw = create_instance(mwcls, settings, crawler)
File “C:\Users\Mr JIE\AppData\Local\Programs\Python\Python37\lib\site-packages\scrapy\utils\misc.py”, line 150, in create_instance
return objcls(*args, **kwargs)
File “C:\Users\Mr JIE\ArticleSpider\ArticleSpider\pipelines.py”, line 62, in init
self.conn = MySQLdb.connect(‘127.0.0.1’, ‘root’, ‘root’, ‘article_spider’, charset=“utf8”, use_unicode=True)
File "C:\Users\Mr JIE\AppData\Local\Programs\Python\Python37\lib\site-packages\MySQLdb_init.py", line 84, in Connect
return Connection(*args, **kwargs)
File “C:\Users\Mr JIE\AppData\Local\Programs\Python\Python37\lib\site-packages\MySQLdb\connections.py”, line 179, in init
super(Connection, self).init(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (1045, “Access denied for user ‘root’@‘localhost’ (using password: YES)”)
2回答
-
夜色小闪
2021-07-22
我把 MySQLdb.connect(‘127.0.0.1’, ‘root’, ‘root’, ‘article_spider’, charset=“utf8”, use_unicode=True)
改成
MySQLdb.connect("localhost", 'root', '123456', 'article_spider', charset="utf8", use_unicode=True)
就解决了
112021-07-23 -
bobby
2020-04-05
这个报错来看是用户名密码错误了 你的用户名密码能使用navicat登录吗?
022020-04-07
相似问题