MYSQL *con = NULL;
con = mysql_init(con);//初始化
if (con == NULL)
{
cout << "MySQL Error1";
}
string url = "localhost"; //主机地址
unsigned int Port = 3306; //数据库端口号
string User = "root"; //登陆数据库用户名
string PassWord = "mysql30wish"; //登陆数据库密码
string DBName = "algorithm"; //使用数据库名
//链接数据库
con = mysql_real_connect(con, url.c_str(), User.c_str(), PassWord.c_str(), DBName.c_str(), Port, NULL, 0);
if (con == NULL)
{
cout << "MySQL Error2";
}
else
{
qDebug() << "connect mysql success";
}
01-17
2万+
2万+

被折叠的 条评论
为什么被折叠?



