一、修改MySQL远程连接权限
- 输入账号和密码进入MySQL界面
- 输入以下代码:
use mysql;
update user set user.Host='Target_IPV4_Address' where user.User='root';
flush privileges;
注意:如果 user.Host=’%’,代表任意一台电脑都可以连接!
二、本地使用pymsql进行远程连接MySQL
import pymysql
db = pymysql.connect(host="IPV4",user="user_name",
password="password",database="database")
cursor = db.cursor()
cursor.execute("show tables") # 查询数据表
output = cursor.fetchall() # 提出数据信息
print(output)