using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
namespace Csharp链接数据库Mysql
{
class Program
{
static void Main(string[] args)
{
string connectStr = "server = 127.0.0.1;port = 3306;database = mygamedb;user=root;password=*********";
MySqlConnection conn = new MySqlConnection(connectStr);
try
{
conn.Open();
Console.WriteLine("已经建立链接");
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
finally
{
conn.Close();
}
Console.ReadKey();
}
}
}