Am使用Raspberry Pi 3记录室温,记录的温度必须发送到我的系统,并且应该存储在mysql数据库中。但是无法远程访问mysql。
我确实授予了所有特权并评论了盲人地址
操作系统:ubuntu 18.04
感谢您的帮助
def main():
while True:
temperature = sensor.get_temperature()
print("The temperature is %s celsius" % temperature)
time.sleep(1)
#Code to write the recorded temperature in the MYSQL
#database 'templog' and table 'temp-at-interrupt'
db = MySQLdb.connect(host="192.168.1.6", user="root",
passwd="root", db="templog")
cur = db.cursor()
print("connected to db")
The temperature is 30.625 celsius
Traceback (most recent call last):
File "temp-3.py", line 47, in <module>
main()
File "temp-3.py", line 25, in main
db = MySQLdb.connect(host="192.168.1.6", user="root", passwd="root", db="templog")
File "/usr/lib/python3/dist-packages/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/usr/lib/python3/dist-packages/MySQLdb/connections.py", line 204, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'root'@'192.168.1.7' (using password: YES)")