python3 PyMySQL 连接 MySQL 数据库问题, win10,如下

2018-04-27 00:44:37 +08:00
 HanYang1

python3 连接 MySQL 数据库问题, win10 在 cmd 上可以使用 root 加 pssword 连上 mysql,mysql -u root -p password; 但是使用 PyMySQL 却连接不上,报 pymysql.err.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: NO)")

CMD 可以连接

Microsoft Windows [版本 10.0.16299.371] (c) 2017 Microsoft Corporation。保留所有权利。

C:\Users\shuer>mysql -u root -p Enter password: *************** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 52 Server version: 8.0.11 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

3307 次点击
所在节点    Python
5 条回复
GooMS
2018-04-27 01:35:19 +08:00
Use password no ?
HanYang1
2018-04-27 07:28:42 +08:00
@GooMS 使得,我 cmd 上可以连,python 那边也写了 password,但还是报错,using password no
vipppppp
2018-04-27 09:05:17 +08:00
你不贴代码,怎么看。。
HanYang1
2018-04-27 11:59:32 +08:00
@vipppppp 就这里 connection = pymysql.connect(host='localhost',
user='root',
db='wocao',
password='xxxxxx')
密码是对的,但报错
HanYang1
2018-04-27 13:39:00 +08:00
ok 啦,不知道为什么用 mysql-connector-python 就 ok 啦

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/450246

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX