Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stuck at Connecting to SQL .... #41

Closed
ericangwyn opened this issue Apr 16, 2018 · 6 comments
Closed

Stuck at Connecting to SQL .... #41

ericangwyn opened this issue Apr 16, 2018 · 6 comments

Comments

@ericangwyn
Copy link

ericangwyn commented Apr 16, 2018

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 <ESP8266WiFi.h> // Use this for WiFi instead of Ethernet.h
#include <MySQL_Connection.h>
#include <MySQL_Cursor.h>

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
Copy link
Owner

ChuckBell commented Apr 16, 2018 via email

@squallus
Copy link

squallus commented May 4, 2018

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
Copy link
Owner

ChuckBell commented May 4, 2018 via email

@StoneAgeSkillz
Copy link

StoneAgeSkillz commented Aug 24, 2018

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

@ChuckBell
Copy link
Owner

Can we close this issue?

@beicnet
Copy link

beicnet commented Jun 19, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants