V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
HanYang1
V2EX  ›  Python

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

  •  
  •   HanYang1 · 2018-04-27 00:44:37 +08:00 · 3281 次点击
    这是一个创建于 2162 天前的主题,其中的信息可能已经有所发展或是发生改变。

    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>

    5 条回复    2018-04-27 13:39:00 +08:00
    GooMS
        1
    GooMS  
       2018-04-27 01:35:19 +08:00 via Android
    Use password no ?
    HanYang1
        2
    HanYang1  
    OP
       2018-04-27 07:28:42 +08:00
    @GooMS 使得,我 cmd 上可以连,python 那边也写了 password,但还是报错,using password no
    vipppppp
        3
    vipppppp  
       2018-04-27 09:05:17 +08:00
    你不贴代码,怎么看。。
    HanYang1
        4
    HanYang1  
    OP
       2018-04-27 11:59:32 +08:00
    @vipppppp 就这里 connection = pymysql.connect(host='localhost',
    user='root',
    db='wocao',
    password='xxxxxx')
    密码是对的,但报错
    HanYang1
        5
    HanYang1  
    OP
       2018-04-27 13:39:00 +08:00
    ok 啦,不知道为什么用 mysql-connector-python 就 ok 啦
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5193 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 09:41 · PVG 17:41 · LAX 02:41 · JFK 05:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.