I have installed spyder with anacoda for python 3.7 version for windows. Then if I print("hello"), it works fine.
Now I want to connect with MYSQL database so I have installed python drivers to communicate with MYSQL. Using Anaconda Prompt I have run below command:
conda install -c anaconda mysql-connector-python
I got message in Anaconda Prompt that packages installed successfully. I don't know how to get username and password to connect with MYSQL? I have already checked that MYSQL installed properly using import mysql.connector.
Code as per below:
import mysql.connector
from mysql.connector import Error
def connect():
try:
conn = mysql.connector.connect(host='127.0.0.1',
user='',
passwd='')
if conn.is_connected():
print('Connected to MySQL database')
except Error as e:
print(e)
connect()
Error:
2003: Can't connect to MySQL server on '127.0.0.1:3306' (10061 No connection could be made because the target machine actively refused it)