一:服务启动
1.我们可以在Windows搜索栏中搜索服务应用功能,或者其他方式打开服务,右键单击选择以管理员运行。
2.在服务中找到MySQL,手动点击启动。
不过用这个方法很可能还是无法启动mysql服务。
二:删除Data
给你个例子:这个是DEV C++编译通过的
#include <windows.h>
#include <iostream>
#include <mysql/mysql.h>
#define SELECT_QUERY "select * from stu "
using namespace std
int main(int argc, char *argv[])
{
//connection params
char *host = "localhost"
char *user = "root"
char *pass = "123"
char *db = "mydb"
//sock
MYSQL *sock
MYSQL_RES *res
sock = mysql_init(0)
if (sock) cout <<"sock handle ok!" <<endl
else{
cout <<"sock handle failed!" <<endl
return EXIT_FAILURE
}
//connection
if (mysql_real_connect(sock, host, user, pass, db, 0, NULL, 0))
cout <<"connection ok!" <<endl
else{
cout <<"connection failed!" <<endl
return EXIT_FAILURE
}
//query
if (mysql_query (sock, SELECT_QUERY ))
{
cout <<"Query failed " <<mysql_error(sock) <<endl
exit(1)
}
if ( !( res = mysql_store_result( sock )))
{
cout <<"Couldn't get result from " <<mysql_error(sock) <<endl
exit(1)
}
MYSQL_FIELD *field
MYSQL_ROW row
while ((field = mysql_fetch_field(res)))
{
printf("field name %s ", field->name)
}
while ( row = mysql_fetch_row ( res ))
{
cout<<row[0]<<" "<<row[1]<<endl
}
system("PAUSE")
//closing connection
mysql_free_result ( res )
mysql_close(sock)
return EXIT_SUCCESS
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)