我装了MYSQL的WINDOWS版本,但是里面的EXAMPLE程序运行 "Can't connect to the mysql server on port 3306!" 为什么呀?是刚装的,例子怎么就不能用了啊? 例子能编译通过了,那为什么连不上呢
网上看了点方法: 1。是用API,可是有以下的问题: 我装了MYSQL的WINDOWS版本,但是里面的EXAMPLE程序运行 "Can't connect to the mysql server on port 3306!" 为什么呀?是刚装的,例子怎么就不能用了啊? 例子能编译通过了,那为什么连不上呢 2。用ODBC数据源,能接上数据库了,但是以前没写过这样的程序,不知道下面该怎么做 3。ADO这个方法看到有,但是没细看,因为不打算用。 上面三种方法,自己想用第一种,因为以前的数据库操作都已经用C写过了,用第一种的话比较方便,直接可以用C的写法写,但是为什么例子程序都连不上呢? 哪位了解这方面的麻烦教一下吧,我真是走进死胡同了。
http://community.csdn.net/Expert/topic/3274/3274758.xml?temp=3.473163E-04
但是编译找不到
#include <MySQL\mysql.h>
怎么弄的啊?
"Can't connect to the mysql server on port 3306!"
为什么呀?是刚装的,例子怎么就不能用了啊?
例子能编译通过了,那为什么连不上呢
1。是用API,可是有以下的问题:
我装了MYSQL的WINDOWS版本,但是里面的EXAMPLE程序运行
"Can't connect to the mysql server on port 3306!"
为什么呀?是刚装的,例子怎么就不能用了啊?
例子能编译通过了,那为什么连不上呢
2。用ODBC数据源,能接上数据库了,但是以前没写过这样的程序,不知道下面该怎么做
3。ADO这个方法看到有,但是没细看,因为不打算用。
上面三种方法,自己想用第一种,因为以前的数据库操作都已经用C写过了,用第一种的话比较方便,直接可以用C的写法写,但是为什么例子程序都连不上呢?
哪位了解这方面的麻烦教一下吧,我真是走进死胡同了。
首先
mysql_init
然后
mysql_real_connect
第一个参数是mysql_init过后的参数
除了port传0外其他都传""
你最好用mysql提供的api来操作.因为在linux下使用odbc或ado都比较麻烦的."Can't connect to the mysql server on port 3306!"你用mysqladmin来启动看看呢?
还有API的话,要设置哪些东东?
mysqladmin,用这个程序来启动你的mysql.在工具栏下方有一个start service.如果是绿灯就表示启动成功了.
一般也是建议用api来操作mysql
datebaseDlg.obj : error LNK2001: unresolved external symbol _mysql_stat@4
datebaseDlg.obj : error LNK2001: unresolved external symbol _mysql_list_tables@8
datebaseDlg.obj : error LNK2001: unresolved external symbol _mysql_error@4
datebaseDlg.obj : error LNK2001: unresolved external symbol _mysql_list_processes@4
datebaseDlg.obj : error LNK2001: unresolved external symbol _mysql_get_server_info@4
datebaseDlg.obj : error LNK2001: unresolved external symbol _mysql_get_host_info@4
datebaseDlg.obj : error LNK2001: unresolved external symbol _mysql_get_client_info@0
datebaseDlg.obj : error LNK2001: unresolved external symbol _mysql_free_result@4
datebaseDlg.obj : error LNK2001: unresolved external symbol _mysql_num_fields@4
datebaseDlg.obj : error LNK2001: unresolved external symbol _mysql_fetch_row@4
datebaseDlg.obj : error LNK2001: unresolved external symbol _mysql_fetch_field@4
datebaseDlg.obj : error LNK2001: unresolved external symbol _mysql_num_rows@4
datebaseDlg.obj : error LNK2001: unresolved external symbol _mysql_store_result@4
datebaseDlg.obj : error LNK2001: unresolved external symbol _mysql_query@8
datebaseDlg.obj : error LNK2001: unresolved external symbol _mysql_close@4
datebaseDlg.obj : error LNK2001: unresolved external symbol _mysql_select_db@8
datebaseDlg.obj : error LNK2001: unresolved external symbol _mysql_real_connect@32
datebaseDlg.obj : error LNK2001: unresolved external symbol _mysql_init@4
Debug/datebase.exe : fatal error LNK1120: 18 unresolved externals
Error executing link.exe.
添加 libmysql.lib
copy D:\mysql\lib\opt\libmysql.lib 到你的程序目录
copy D:\mysql\bin\libmySQL.dll 到你的程序目录