Bonjour a tous,
J'essaie d'envoyer une donnée dans une base de données sur mon hébergement.
Apparemment j'arrive a me connecter a la base de données, mais pas a y enregistrer ma donnée, et je ne vois pas ou ça bloque.
Voici mon code:
#include <ESP8266WiFi.h> // Use this for WiFi instead of Ethernet.h
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>
IPAddress server_addr(1,4,31,1); // IP of the MySQL *server* here
char user[] = "user"; // MySQL user login username
char password[] = "MdP"; // MySQL user login password
// Sample query
char INSERT_SQL[] = "INSERT INTO test_arduino.hello_arduino (message) VALUES ('Hello, Arduino!')";
// WiFi card example
char ssid[] = "SSID"; // your SSID
char pass[] = "MdP"; // your SSID Password
WiFiClient client; // Use this for WiFi instead of EthernetClient
MySQL_Connection conn(&client);
MySQL_Cursor* cursor;
void setup()
{
Serial.begin(115200);
while (!Serial); // wait for serial port to connect. Needed for Leonardo only
// Begin WiFi section
Serial.printf("\nConnecting to %s", ssid);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
// print out info about the connection:
Serial.println("\nConnected to network");
Serial.print("My IP address is: ");
Serial.println(WiFi.localIP());
Serial.print("Connecting to SQL... ");
if (conn.connect(server_addr, 3306, user, password))
Serial.println("OK.");
else
Serial.println("FAILED.");
// create MySQL cursor object
cursor = new MySQL_Cursor(&conn);
}
void loop()
{
if (conn.connected())
cursor->execute(INSERT_SQL);
delay(5000);
}
et voici ce que j'ai dans le moniteur:
Connecting to SSID.............
Connected to network
My IP address is: 192.168.0.24
Connecting to SQL... ...trying...
Connected to server version 5.5.5-10.5.13-MariaDB-cll-lve
OK.
Error: 101 = INSERT command denied to user 'u984373661_treza88'@'85.168.31.223' for table 'hello_arduino'.
Error: 101 = INSERT command denied to user 'u984373661_treza88'@'85.168.31.223' for table 'hello_arduino'.
Error: 101 = INSERT command denied to user 'u984373661_treza88'@'85.168.31.223' for table 'hello_arduino'.
Error: 101 = INSERT command denied to user 'u984373661_treza88'@'85.168.31.223' for table 'hello_arduino'.
Error: 101 = INSERT command denied to user 'u984373661_treza88'@'85.168.31.223' for table 'hello_arduino'
Merci d'avance