简体   繁体   中英

Connect to local MySql database using C#

I'm trying to get a connection to my local MySQL database, I'm not sure what all the parameters are. Hopefully someone can help.

My code:

string connetionString = "Server = 127.0.0.1; Database = name of database; User Id = root, Password = password of database";

SqlConnection cnn = new SqlConnection(connetionString);

try
{
    cnn.Open();
    MessageBox.Show("Connection Open ! ");
    cnn.Close();
}
catch (Exception ex)
{
    MessageBox.Show(ex.ToString(), "titel", MessageBoxButtons.OK);
    MessageBox.Show("Can not open connection ! ");
}

Thanks

您可以尝试将连接字符串设置为

server=127.0.0.1;database={dbname};uid={};password=password@1;Max Pool Size=800;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM