On the MySQL server you need to allow the IP address for the ESP32 to access the server. I would look for MySQL articles on remote access rather than stackoverflow for better information.
IP address 127.0.0.1 is the local host address, probably for local client access.
Sorry I don't have more information, but it has been years since I have done remote MySQL access.
infinite knowledge on the ESP32 won't solve for this...
You need to be familiar with Windows and with MySQL...
It boils down to editing the MySQL config file in the right way, changing the bind-address so that it's not localhost only and making sure that the port used by MySQL is open in your firewall
You need also to grant access in the right way to your DB
I don't (want to) have a windows machine, so don't know the details
When connecting to a network, Windows tends to ask how they should treat it - as a public network with lots of protection, or a private network allowing access from other devices to it. You need to choose the latter in order for Windows Defender to actually allow any network connections to be made to the machine.
I used mostly Linux rather than Windows for the server and client.
I used C++ and Python for the connection. You need to be able to run the MySQL APIs on your processor. I don't know if there is a version for the ESP32.
It may be easier to run the MySQL on the PC and use a web or TC/IP interface to the ESP32
I do not directly access MySQL server using ESP32's. I indirectly access MySQL server using ESP32's.
I run on the ESP32's MQTT PuSubClient that publishes to my MTT Broker, a Raspberry Pi. The RPi collects the data and directly access MySQL server, where it puts data from the ESP32's into the Db and retrieves data from the Db to send to the ESP32's. Much easier way to do it but more costly. On the other hand, my RPi is doing TensorFlow on images produced by the ESP32's, doing the FTP server thing, running a Python program for further data processing and distribution and a few other server chores.
The data on the server is accessed by my website where I use my website and a command and control center.
I have 13 ESP32's located throughout my house and backyard. Buying 13 RPi's and powering them in my attic, crawlspace and backyard would be problematic and expensive.
I do not wish for the ESP32's to have direct access to the internet.
If you do use a RPi and Python and create multiple dB connections use the MySQL connection pool and make sure the creation of the connection pool is the very first thing that your program does. I found the connection pool does not like being 2nd or 3rd or 5th. No threads and no multi-processes before the connection pool has completely initialized.
Just something to keep in mind. It took me months to figure that one out.