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.
1 Answer 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)