0%

CodeBlock下载

2)codeblock安装

​ 2-1)官网 https://www.codeblocks.org/

img

​ 2-2)点击下载

img

2-3)选择对应平台

img

img

2-4)安装即可

img

2-5)配置依赖库和include库

img

Setting中第三个Compiler

img

img

img

2-6)创建工程

img

img

2-7)将libmysql.dll复制到工程中

img

img

2-8)运行结果

img

img

文件:main.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62

\#include <iostream>

\#include "mysql.h"



using namespace std;

int main()

{

cout << "Hello, world!" << endl;

// q1();

MYSQL conn;

int res;

mysql_init(&conn);

if (mysql_real_connect(&conn, "127.0.0.1", "root", "root", "test", 3306, NULL, CLIENT_FOUND_ROWS))

{

printf("connect success!\n");

​ res = mysql_query(&conn, "insert into account values('lisi','9999')");

if (res)

​ {

printf("error\n");

​ }

else

​ {

printf("OK\n");

​ }

mysql_close(&conn);

}

else

{

printf("connect errot!\n");

}

return 0;

}
-------------本文结束感谢您的阅读-------------