[C++]MySQLÊý¾Ý¿â²Ù×÷ʵÀý
»·¾³ÉèÖãº
°²×°ÍêMySQLÖ®ºó£¬½«°²×°Ä¿Â¼ÖеÄincludeĿ¼ÏµÄlibmysql.libÎļþ¿½µ½VS2008°²×°Ä¿Â¼ÖеÄVC\lib\Ï£¬È»ºóÔÚ ÏîÄ¿-Ñ¡Ïî-c/c++-³£¹æ Öеĸ½¼Ó°üº¬Ä¿Â¼ÒÔ¼° Á´½ÓÆ÷-³£¹æ Öеĸ½¼Ó¿âĿ¼ÖмÓÈë“c:\MySQL\include\”£¬²¢ÇÒÔÚ Á´½ÓÆ÷-ÊäÈë Öеĸ½¼ÓÒÀÀµÏîÄÚÌí¼Ó“libmysql.lib”£¬ÕâÑù¼´¿Éʹ±àÒëÆ÷ÕÒµ½mysql.hÍ·Îļþ£¬²¢¿ÉÔÚ³ÌÐòÖÐʹÓÃcÓïÑÔµÄmysql APIÀ´²Ù×÷Êý¾Ý¿â¡££¨Èç¹ûMySQL°²×°Ä¿Â¼ÖÐÎÞincludeĿ¼£¬¿Éµ½MySQL¹ÙÍøÏÂÔز¢°²×°MySQL connector for C£¬²¢ÐÞ¸ÄincludeĿ¼·¾¶£©
´úÂëʾÀý£º
#include <Windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mysql.h>
#include <iostream>
using namespace std;
int main()
{
const char user[] = "root"; //username
const char pswd[] = "root"; //password
const char host[] = "localhost"; //or"127.0.0.1"
const char table[] = "test"; //database
unsigned int port = 3306; //server port
MYSQL myCont;
MYSQL_RES *result;
MYSQL_ROW sql_row;
MYSQL_FIELD *fd;
char column[32][32];
int res;
mysql_init(&myCont);
if(mysql_real_connect(&myCont,host,user,pswd,table,port,NULL,0))
{
cout<
Ïà¹ØÎĵµ£º
http://www.mysql.cn/
ÊÂÎñ£¬²ÎÊý£¬Ç¶Ì×µ÷Óã¬Óα꣬ѻ·, ´¥·¢Æ÷£¬ÊÓͼ£¬Ô¼Êø, Ë÷Òý£¬¡£¡£¡£
1. ´´½¨ÊµÀýÊý¾Ý¿â
create database db5;
use db5;
2.´´½¨Ò»¸ö¼òµ¥µÄ¹¤×÷±í,²¢²åÈëÊý¾Ý
create table t(s1 int);
insert into t values(5);
3.´´½¨³ÌÐòʵÀý crea ......
create procedure getInfor2()
BEGIN
declare _abc varchar(200);
declare stopFlag int;
DECLARE cursor_name CURSOR
FOR
select zhuanyuan from server;
DECLARE CONTINUE HANDLER FOR NOT FOUND set stopFlag=1;
OPEN cursor_name;
REPEAT
FETCH cursor_name INTO _abc;
begin
if _abc='root'
the ......
×î½üÓõ½ÁËÒ»¿îÊý¾Ý¿âͼÐλ¯¹ÜÀí¹¤¾ßNavicat for MySQL £¬Ê¹ÓÃÖ®ºóÓÐÒ»Öָоõ£ºÔÀ´±à³Ì¿ÉÒԺܸßЧ£¡
ÒÔǰʹÓÃMySQLʱ£¬Ã¿´Î¶¼Ö»ÄÜÔÚÀàËÆDOSµÄ½çÃ濪·¢£¬Ê¹Óùٷ½ÌṩµÄ¹¤¾ßºÜÈÝÒ׾ͱ»¿¨µ½ÁË£¬¾õµÃ»¹ÊÇ×ÖÌõ½çÃæ±È½Ï¸ßЧ£¬µ«ÊdzõѧMySQL,ºÜ¶à¹¦Äܶ¼»¹Ã»ÓÐÍêÈ«Çå³þ£¬Ê¹Óð²È«ÐÔÉϵĿ¼ÂÇÒ²²»¹»³ÉÊì¡£ÕâʱºòÎÒ¿ ......
MySQL5.X¶¼ÒѾ·¢²¼ºÃ¾ÃÁË£¬µ«ÊÇ»¹ÓкܶàÈËÈÏΪMySQLÊDz»Ö§³ÖÊÂÎñ´¦ÀíµÄ£¬Õâ²»µÃ²»¹ÖËûÃÇÊǹª¹ÑÎŵģ¬Æäʵ£¬Ö»ÒªÄãµÄMySQL°æ±¾
Ö§³ÖBDB»òInnoDB±íÀàÐÍ£¬ÄÇôÄãµÄMySQL¾Í¾ßÓÐÊÂÎñ´¦ÀíµÄÄÜÁ¦¡£ÕâÀïÃ棬ÓÖÒÔInnoDB±íÀàÐÍÓõÄ×î¶à£¬ËäÈ»ºóÀ´·¢ÉúÁËÖîÈçOracleÊÕ
¹ºInnoDBµÈÁîMySQL²»Ë¬µÄÊÂÇ飬µ«ÄÇЩÉÌÒµÉϵĶ·ÕùÓë¼¼ÊõÎ޹أ ......
MYSQLÓв»Í¬ÀàÐ͵ÄÈÕÖ¾Îļþ(¸÷×Ô´æ´¢Á˲»Í¬ÀàÐ͵ÄÈÕÖ¾)£¬´ÓËüÃǵ±ÖпÉÒÔ²éѯµ½MYSQLÀﶼ×öÁËЩʲô£¬¶ÔÓÚMYSQLµÄ¹ÜÀí¹¤×÷£¬ÕâЩÈÕÖ¾ÎļþÊDz»¿ÉȱÉٵġ£
1.´íÎóÈÕÖ¾(The error log)£º¼Ç¼ÁËÊý¾Ý¿âÆô¶¯¡¢ÔËÐÐÒÔ¼°Í£Ö¹¹ý³ÌÖдíÎóÐÅÏ¢£»
2.ISAM²Ù×÷ÈÕÖ¾(The isam log)£º¼Ç¼ÁËËùÓжÔISAM±íµÄÐ޸ģ¬¸ÃÈÕÖ¾½ö½öÓÃÓÚµ÷ÊÔISAMģʽ ......