I am trying to retrieve my data from MySQL to be used in python. But it prints out TypeError: 'NoneType' object is not iterable
The server log shows that Access denied for user 'root'@'localhost' (using password: NO)
This is the server log . Thanks in advance!
Edit: This is the python code
import pandas as pd
user, pw, host, db = 'root', '12345', '127.0.0.1', 'ca2database'
cnx = mysql.connector.connect(user=user, password=pw, host=host, database=db)
cursor = cnx.cursor()
df= pd.read_sql('SELECT * FROM student', con=cnx)
print(df)
cursor.close()
cnx.close()
and this is the data in the sql
localhost
yet the arg passed equals127.0.0.1
? The MySQL security forroot
is host part specific usually so this may matter. Outside of the Python connection, can you access the MySQL instance as root and check security to see how it is configured? I'd guess yourpw
arg is null too. Unfortunately I don't knowpandas
very well either.cnx = mysql.connector.connect(user='root', password='12345', host='localhost', database='ca2database')
But it still produces the same output. And i need the ' quotation if not it will say the variable is not defined.127.0.0.1
instead oflocalhost
and see if that makes any difference. Also, try all variations of those values with double quotes rather than single quotes too.