EKsumic's Blog

let today = new Beginning();

Click the left button to use the catalog.

OR

How to connect to MySQL using .NET Core How should I write the connection string?

MySQL Connector/Net (.NET) standard connection method

1. Standard connection (Note, the default port is 3306.)

Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;


2. Special TCP/IP port connection

Server=myServerAddress;Port=1234;Database=myDataBase;Uid=myUsername;Pwd=myPassword;

Local connection should write

Server=/var/run/mysqld/mysqld.sock

As for localhost and 127.0.0.1, if you can use it, it is recommended to write localhost, because localhost does not go through the network layer, firewall, etc., theoretically the performance is higher.

But when I was testing, neither localhost nor 127.0.0.1 could be used, but the public IP was fine...

It was also strange at the time, and then I thought it was because I commented out the similar statement bind localhost=127.0.0.1 in a configuration file.

But this is not going to be verified, and I will add it later.

This article was last edited at 2020-11-05 01:08:20

* *