0

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)

MatthewMartin
33.3k33 gold badges117 silver badges172 bronze badges
asked Mar 1, 2017 at 13:31
7
  • Possible duplicate of Accessing MySQL from Python 3: Access denied for user Commented Mar 1, 2017 at 13:33
  • Use non-empty password; It works. Commented Mar 1, 2017 at 13:34
  • I have tried a space for the password and I have the same problem @Sangharsh Commented Mar 1, 2017 at 13:35
  • thank you @vishes_shell, I have seen this post, it didn't help. Commented Mar 1, 2017 at 13:37
  • conn = mysql.connector.connect(user='root', password='root'); works. (Assuming root password is root) Commented Mar 1, 2017 at 13:37

1 Answer 1

1

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')
answered Mar 1, 2017 at 13:39
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.