我正在从事一个项目,其中包括从 mq6 传感器感测气体粒子并达到大约。从中读取并将这些读数发送到我的 Windows 桌面上 wamp 服务器中的 mysql 数据库。我已经设置了数据库和表,用于在 wamp 服务器上的 mysql 数据库中存储数据。 我正在使用以下代码使用 python 脚本从我的树莓派连接到外部 mysql 数据库。
import MySQLdb
try:
conn = MySQLdb.connect(host="192.168.*.*",
user="username",
passwd="password",
db="databasename")
c = conn.cursor()
except MySQLdb.Error,e:
print "Mysql Error %d: %s" % (e.args[0], e.args[1])
执行代码后出现如下错误:
Mysql Error 1045: Access denied for user 'username'@'192.168.*.*' (using password: YES)
我认为我桌面上的 wamp 服务器中的 raspberry python 脚本和 mysql 数据库之间没有建立连接。 真的需要帮助来解决它。我已经尝试了一切,现在我没有选择了。
最佳答案
在我看来,实际上连接已建立。您看到的错误是权限问题。试试这个:MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)
关于python - 如何使用 python 脚本从我的树莓派访问 Windows 桌面上 wamp 服务器中的外部 mysql 数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36011399/