- 论坛徽章:
- 1
|
- #include <stdio.h>
- #include <mysql/mysql.h>
- MYSQL mysql;
- int connect()
- {
- char host[32] = "255.255.255.255"; /*localhost*/
- char user[32] = "ererer";
- char passwd[32] = "123456";
- char db[32] = "data"; /*what database*/
-
- if( mysql_init(&mysql) == NULL )
- {
- fprintf(stderr,"Init mysql err!");
- return -1;
- }
- if (mysql_real_connect(&mysql,host,user,passwd,db,0,NULL,0) == NULL)
- {
- fprintf(stderr,"Connect to mysql Error:%s!",mysql_error(&mysql));
- return -1;
- }
- else
- {
- puts("Connect to mysql success!");
- }
-
-
-
- return 0;
- }
- int main()
- {
- int i,j,k;
- connect();
- return 0;
- }
复制代码
上面是我的代码,host为局域网内的一台主机,运行时显示:
Can't create TCP/IP socket (24)
Can't connect to MySQL server on '192.168.0.59
这是什么原因啊???
[ 本帖最后由 ecjtubaowp 于 2008-10-23 10:41 编辑 ] |
|