ChuckBell / MySQL_Connector_Arduino

Database connector library for using MySQL with your Arduino projects.
332 stars 133 forks source link

Stuck at Connecting to SQL .... #41

Closed ericangwyn closed 2 years ago

ericangwyn commented 6 years ago

when i try to start the code below my nodemcu can connect to network already got IP and when it get into the connecting to sql the process just stop. Can someone figure why ? ,im using xampp phpmyadmin as database

include // Use this for WiFi instead of Ethernet.h

include

include

IPAddress server_addr(192, 168, 1, 100); // IP of the MySQL server here char user[] = "root"; // MySQL user login username char password[] = ""; // MySQL user login password

// Sample query char INSERT_SQL[] = "INSERT INTO test_arduino.hello_arduino (message) VALUES ('Hello, Arduino!')";

// WiFi card example char ssid[] = "x"; // your SSID char pass[] = "x"; // 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); }

ChuckBell commented 6 years ago

Did you modify the connect replacing Ethernet.h with the ESPWifi header file!

On Mon, Apr 16, 2018 at 10:04 testsubject notifications@github.com wrote:

when i try to start the code below my nodemcu can connect to network already got IP and when it get into the connecting to sql the process just stop. Can someone figure why ? ,im using xampp phpmyadmin as database

include // Use this for WiFi instead of Ethernet.h

include

include

IPAddress server_addr(192, 168, 1, 100); // IP of the MySQL server here char user[] = "root"; // MySQL user login username char password[] = ""; // MySQL user login password

// Sample query char INSERT_SQL[] = "INSERT INTO test_arduino.hello_arduino (message) VALUES ('Hello, Arduino!')";

// WiFi card example char ssid[] = "x"; // your SSID char pass[] = "x"; // 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); }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/41, or mute the thread https://github.com/notifications/unsubscribe-auth/AH0j4Oo3oj1yPEvz8VR21vAeLKBiM75Fks5tpKUIgaJpZM4TWllR .

squallus commented 6 years ago

XAMP uses MariaDB not original OracleMySQL, i have an similar issue, maybe this is the problem. Lets hope there is an solution to this.

ChuckBell commented 6 years ago

Correct. The connectir does not work with anything other than Oracle’s MySQL. Your only option is to uninstall the existing variant and install MySQL. For best results, install MySQL 5.7. Version 8.0 will work but you must enable the legacy password encryption.

On Fri, May 4, 2018 at 18:11 squallus notifications@github.com wrote:

XAMP uses MariaDB not original OracleMySQL, i have an similar issue, maybe this is the problem. Lets hope there is an solution to this.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/41#issuecomment-386748268, or mute the thread https://github.com/notifications/unsubscribe-auth/AH0j4PqD-M87F8dv_8np4ANAdKF2KggSks5tvNIugaJpZM4TWllR .

StoneAgeSkillz commented 6 years ago

Had the same problem, it's permission issue. Added user permissions to mysql and it works now.

ChuckBell commented 5 years ago

Can we close this issue?

beicnet commented 4 years ago

@ChuckBell Can you maybe add support for MariaDB? Thanks! 😉