ChuckBell / MySQL_Connector_Arduino

Database connector library for using MySQL with your Arduino projects.
331 stars 132 forks source link

Connect to local MySQL #129

Closed rodrigotabsan closed 2 years ago

rodrigotabsan commented 4 years ago

Hi,

I am trying to connect to 127.0.0.1 where I have a MySQL Server created with Wamp (phpMyAdmin). The connect example can't connect to my database... what am i doing wrong?

Here is the code that I am using:

``#include

include

byte mac_addr[] = { 0x30, 0x5B, 0x3A, 0x7A, 0x0C, 0x0G };

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

EthernetClient client; MySQL_Connection conn((Client *)&client);

void setup() { Serial.begin(9600); while (!Serial); // wait for serial port to connect Ethernet.begin(mac_addr); Serial.println("Connecting..."); if (conn.connect(server_addr, 3306, user, password)) { delay(1000); // You would add your code here to run a query once on startup. } else Serial.println("Connection failed."); conn.close(); }

void loop() { }``

Port is ok, password is ok and user is ok... what am i doing wrong?

I am using MySQL 8

Thanks in advance

ChuckBell commented 4 years ago

You cannot use the loopback address. You must use the IP address of the computer hosting MySQL.

On Sat, Apr 4, 2020 at 14:07 rodrigotabsan notifications@github.com wrote:

Hi,

I am trying to connect to 127.0.0.1 where I have a MySQL Server created with Wamp (phpMyAdmin). The connect example can't connect to my database... what am i doing wrong?

Here is the code that I am using:

`#include

include

byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

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

EthernetClient client; MySQL_Connection conn((Client *)&client);

void setup() { Serial.begin(9600); while (!Serial); // wait for serial port to connect Ethernet.begin(mac_addr); Serial.println("Connecting..."); if (conn.connect(server_addr, 3306, user, password)) { delay(1000); // You would add your code here to run a query once on startup. } else Serial.println("Connection failed."); conn.close(); }

void loop() { }`

Thanks in advance

— 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/129, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6SHYEWJ65MWIURTYNEHOLRK5ZNXANCNFSM4L6ZYLMQ .