我正在尝试从一个虚拟的Raspberry PI连接到mysql,我在VirtualBoxVM中运行了它。在
使用Python脚本:import mysql.connector
mydb = mysql.connector.connect(
host="MBP",
user="PI-2",
passwd="",
database="temperatureData"
)
mycursor = mydb.cursor()
sql = "INSERT INTO temperature (date, temp_celsius, temp_farenheit)
VALUES (%s, %s, %s)"
val = ("2019-01-14", "20")
mycursor.execute(sql, val)
mydb.commit()
print(mycursor.rowcount, "record inserted.")
但由于错误而失败:
^{pr2}$
在Mysql(在我的Macbook上)中,我通过以下方式设置用户:
^{3}$
在我的.cnf文件:# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
# bind-address = 127.0.0.1
bind-address = 0.