我在raspberry pi中有代码,它应该将传感器数据发送到windows 7的远程mysql服务器。我已经在raspberry地址中修改了my.cnf文件的bind-address,我也完成了如下设置,
全部取消。''root'@'%'由'mumbai'识别;
FLUSH PRIVILEGES;
我的代码如下,
import MySQLdb
def temp_sensor():
conn = MySQLdb.connect(host = '192.168.1.103', user = 'root', passwd
= 'mumbai', db = 'weather', port = 3306)
cursor = conn.cursor()
while True:
try:
date = time.strftime("%d/%m/%Y")
temp,humidity,light = main.reading()
args= ('192.168.1.145', 'b8:27:eb:06:e4:4b', 'Temp_PI', temp)
cursor.callproc('SPR_IU_Sensor_Data',args)
conn.commit()
time.sleep(interval2)
except MySQLdb.Error, e:
print 'Error %d: %s' % (e.args[0], e.args[1])
给出错误,
Process Process-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/process.py", line 258,
self.run()
File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "procedure2.py", line 19, in temp_sensor
conn = MySQLdb.connect(host = '192.168.1.103', user = 'root',
passwd = 'mumbai', db = 'weather', port = 3306)
File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line
81, in Connect
return Connection(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line
187, in __init__
super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (1130, "Host '192.168.1.145' is not allowed to
connect to this MySQL server")
答案 0 :(得分:0)
他们需要在Windows 7的mysql服务器中授予权限