Closed luckydalanzhu closed 3 years ago
You must use the IP address of your MySQL server, not the loop back address.
On Nov 4, 2020, at 21:14, luckydalanzhu notifications@github.com wrote:
include
include
byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
I only chang two field,ip address and password. When I upload is complete, in the serial port monitor show "Connection failed." Mysql password is correct, I verified it with the Navicat for MySQL. php and mysql environment is powered by xampp.
IPAddress server_addr(127,0,0,1); // IP of the MySQL server here char user[] = "root"; // MySQL user login username char password[] = "password"; // MySQL user login password
EthernetClient client; MySQL_Connection conn((Client *)&client);
void setup() { Serial.begin(115200); 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() { }
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
Like this? IPAddress server_addr(192,168,1,110); // IP of the MySQL server here The laptop's ip address is 192.168.1.110,and i have installed xampp on this laptop.
Sorry,i forgot an important thing.When I upload the code to the 8266 chip, it will connect to MySQL through the network. So,i will try "Connect with WiFi (connect_wifi.ino)".
When i use
Connect with WiFi (connect_wifi.ino)
serial monitor show as below.
------------------ 原始邮件 ------------------ 发件人: "ChuckBell/MySQL_Connector_Arduino" <notifications@github.com>; 发送时间: 2020年11月5日(星期四) 上午10:24 收件人: "ChuckBell/MySQL_Connector_Arduino"<MySQL_Connector_Arduino@noreply.github.com>; 抄送: "39912878"<39912878@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [ChuckBell/MySQL_Connector_Arduino] When i try to run code"Hello, MySQL! (connect.ino)",it show "Connection failed." (#161)
You must use the IP address of your MySQL server, not the loop back address.
> On Nov 4, 2020, at 21:14, luckydalanzhu <notifications@github.com> wrote: > > > #include <Ethernet.h> > #include <MySQL_Connection.h> > > byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; > > I only chang two field,ip address and password. > When I upload is complete, in the serial port monitor show "Connection failed." > Mysql password is correct, I verified it with the Navicat for MySQL. > php and mysql environment is powered by xampp. > > IPAddress server_addr(127,0,0,1); // IP of the MySQL server here > char user[] = "root"; // MySQL user login username > char password[] = "password"; // MySQL user login password > > EthernetClient client; > MySQL_Connection conn((Client *)&client); > > void setup() { > Serial.begin(115200); > 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() { > } > > — > You are receiving this because you are subscribed to this thread. > Reply to this email directly, view it on GitHub, or unsubscribe.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
19:13:46.921 -> ⸮a⸮⸮⸮,⸮TR#⸮!⸮ 19:13:46.921 -> ets Jan 8 2013,rst cause:4, boot mode:(3,0) 19:13:46.921 -> 19:13:46.921 -> wdt reset 19:13:46.921 -> load 0x4010f000, len 1392, room 16 19:13:46.921 -> tail 0 19:13:46.921 -> chksum 0xd0 19:13:46.921 -> csum 0xd0 19:13:46.921 -> v3d128e5c 19:13:46.921 -> ~ld
You need to supply the correct user id and password. Please read the troubleshooting section on the Wiki.
include
include
byte mac_addr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
I only chang two field,ip address and password. When I upload is complete, in the serial port monitor show "Connection failed." Mysql password is correct, I verified it with the Navicat for MySQL. php and mysql environment is powered by xampp.
IPAddress server_addr(127,0,0,1); // IP of the MySQL server here char user[] = "root"; // MySQL user login username char password[] = "password"; // MySQL user login password
EthernetClient client; MySQL_Connection conn((Client *)&client);
void setup() { Serial.begin(115200); 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() { }