Python讀取mysql出現Authentication plugin 'caching_sha2_password' is not supported解決方法
用mysql.connector在讀取MySQL時如下程式碼
cnx = mysql.connector.connect(user='ccc', password='bbb',
host='172.00.000.000',
database='aaa')
cursor = cnx.cursor()
query = ("SELECT xxx FROM aaa;")
cursor = cnx.cursor(buffered=True)
cursor.execute(query)
在mySQL8.0預設caching_sha2_password加密,但套件不支援,所以必須加上一行把預設加密改為mysql_native_password
cnx = mysql.connector.connect(user='ccc', password='bbb',
host='172.00.000.000',
database='aaa',
auth_plugin='mysql_native_password')
即可
cnx = mysql.connector.connect(user='ccc', password='bbb',
host='172.00.000.000',
database='aaa')
cursor = cnx.cursor()
query = ("SELECT xxx FROM aaa;")
cursor = cnx.cursor(buffered=True)
cursor.execute(query)
在mySQL8.0預設caching_sha2_password加密,但套件不支援,所以必須加上一行把預設加密改為mysql_native_password
cnx = mysql.connector.connect(user='ccc', password='bbb',
host='172.00.000.000',
database='aaa',
auth_plugin='mysql_native_password')
即可
留言
張貼留言