2

I understand the error was discussed somewhere online, however mine is a bit different here:

I have a script to be finished in PyCharm (I like to use the debug function there), the script has the following code to connect to a local mysql database:

try:
 # create connection to mysql
 connection = mysql.connector.connect(host='localhost',
 database='<the db>',
 user='<the user>',
 password='<the password>')
except mysql.connector.Error as error:
 print("Error: {}".format(error))
finally:
 print("MySQL connection cannot be established")

I received the following error in PyCharm:

2003: Can't connect to MySQL server on 'localhost:3306' (10060 A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond)

But I do not receive error in mysql console.

How do I fix the issue?

Thank you very much.

asked Feb 21, 2020 at 15:04

1 Answer 1

1

I found the fix to my issue:

mysql> grant all on *.* to '<the user>@localhost' identified by '<the password>' with gran
t option;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.03 sec)
answered Feb 21, 2020 at 15:44
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.