host ‘‘ is not allowed to connect to this mysql server Connect MYSQL Error

1. When you plan to open your database with MySQL – H (IP address of host) – U (user name) – P, the error host ‘is not allowed to connect to this MySQL server is reported
reason: remote login is not allowed in MySQL Step 1: MySQL – U (user name) – P
Step 2: enter use MySQL
Step 3: enter update user set host = ‘%’ where user =’root ‘

4. After connecting, test example:

import pymysql

#Establish a connection
conn = pymysql. Connect (
0   Host =
your IP address   user=”root”,  # User name
Passwd = “root”, # user password
0   DB = (test) # database name

#To create a cursor, the default is meta group type
cursor = conn.cursor()
sql = “select * from student” # the name of the table in the database

cursor.execute(sql)
res = cursor.fetchall()
print(res)

cursor.close()
conn.close()


Read More: