db = MySQLdb.connect(host="127.0.0.1",user="userpython",passwd="root",db="bigdata",port=8886)
对于我来说,添加端口号并没有起作用。授予运行Python脚本的操作系统用户权限是有效的。
sudo mysql -u root -h localhost -p
grant all privileges on database_name.* to 'os_user'@'localhost' identified by
'password' with grant option;
MySQLdb.connect()
函数中缺少端口号。
请确保您已正确添加所有参数,确认用户名和密码有效。以下是示例:
db = MySQLdb.connect(
host="localhost",
user="username",
password="password",
database="database_name",
)