Accessing MySQL from Python 3: Access denied for user

前端 未结 8 1634
鱼传尺愫
鱼传尺愫 2021-01-12 05:16

I tried to access MySQL from Python 3.3 with the following methods:

import mysql.connector

config = {
  \'user\': \'###\',
  \'password\': \'******\',
  \'h         


        
相关标签:
8条回答
  • 2021-01-12 05:47

    I was having lots of trouble with this same task. Here's what worked for me:

    I had to initialize a new database using the legacy password encryption option (compatible with MySQL 5.x):

    Database initialization options screenshot

    Once I did that, everything worked fine. I got that suggestion from this article:

    https://tableplus.com/blog/2018/07/failed-to-load-caching-sha2-password-authentication-plugin-solved.html

    And here are some specs:

    • I'm using Python 3.7
    • I have MySQL 8.0.17 and mysql-connector-python 2.0.4 installed
    0 讨论(0)
  • 2021-01-12 05:49

    I was getting this error because I had quotes in my config file.

    [mysql]
    username: 'uuuu'
    password: 'pppp'
    host: 'localhost'
    database: 'ffffdd'
    

    gave me the error. However, removing the quotes worked:

    [mysql]
    username: uuuu
    password: pppp
    host: localhost
    database: ffffdd
    
    0 讨论(0)
提交回复
热议问题