简体   繁体   中英

Python, Mysql : localhost connexion failed

I want to access my local Mysql database, I am using

import mysql.connector
conn = mysql.connector.connect(user='root',
         password='',
         host='127.0.0.1')

But I have the following error :

mysql.connector.errors.ProgrammingError: 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Thank you for your help.

Use non-empty password. MySQL by default is not accessible to root used without password.

Given error says:

(using password: NO)

Use with password:

import mysql.connector
conn = mysql.connector.connect(user='root',
         password='root',
         host='127.0.0.1')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM