Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

WindowsÏÂÓÃGCCÁ¬½ÓMySQLÊý¾Ý¿â

    Ò»¸öÍøÓÑÔÚ̳×ÓÉÏÎʵ½µÄÎÊÌ⣬˵ÓÃMinGW GCC±àÒëÔËÐÐÒ»¸öÁ¬½ÓMySQLÊý¾Ý¿âµÄ³ÌÐòʱÓöµ½´íÎó£º
undefined reference to `mysql_init@4'
undefined reference to `mysql_real_connect@32'
undefined reference to `mysql_close@4'

    ÎÒËìÈ¥MySQL¹ÙÍøÏÂÁ˸ö×îеÄWindows C Connector£¬È»ºó°´Õý³£Ë¼Â·Ð´Á˸ö×î¼òµ¥µÄÁ¬½Ó²âÊÔ³ÌÐò£¬¹ûÈ»³öÏÖÁËͬÑùµÄ´íÎó¡£
    ºóÀ´ÔÚÍøÉϲéÁËÏ£¬Ò²¿´ÁËÏÂMysql¹ÙÍøÉϱðÈ˵ÄÌÖÂÛ£¬¾Ý³ÆMySQL¹Ù·½ÏÂÔصÄWindows C¿ª·¢°üÖ»ÄÜÔ­Éú̬֧³ÖCL±àÒëÆ÷£¬¶øÓÃGCCÒ²²¢·Ç²»¿É£¬Ö»ÊÇÐèÒª×öһЩ¶îÍâµÄ¹¤×÷¡£ÏȽ«ºóÀ´ÊÔÑé³É¹¦µÄ²½Öè±Ê¼ÇÓÚ´Ë£¬Ö÷Òª²Î¿¼ÓÐhttp://dev.mysql.com/doc/refman/5.0/en/windows-client-compiling.html¡£
    ÏÈÏÂÔØÒ»ÏÂMinGW¹¤¾ß°ü£¬ÏÂÔصØÖ·ÊÇhttp://prdownloads.sourceforge.net/mingw/mingw-utils-0.2.tar.gz?download
    ½âѹ£¬½«´Ë¹¤¾ß°üÖеÄbinĿ¼¼ÓÈëϵͳ»·¾³±äÁ¿µÄPath±äÁ¿¡£
    ÔÚMysql¿ª·¢°üµÄlibĿ¼Ï£¬¼´libmysql.libºÍlibmysql.dllµÄËùÔÚĿ¼£¬ÔËÐÐ
reimp -d libmysql.lib

    µÃµ½µ¼³öÎļþLIBMYSQL.def£¬
    È»ºóÔÚ´ËĿ¼ÔËÐÐMinGW GCC±¾Éí×Ô´øµÄÃüÁî
dlltool -k -d libmysql.def -l libmysql.a

    µÃµ½ÎÒÃÇ×îºóÐèÒªÁ´½ÓµÄ¿âÎļþlibmysql.a¡£
    ÔÚMysql¿ª·¢°üµÄĿ¼ÏÂ(¼´ÓëincludeºÍlibͬ¼¶)н¨ÎÒÃǵIJâÊÔÎļþmain.c£¬²âÊÔÔ´ÂëÈçÏ£º
#include <stdio.h>
#include <winsock2.h>
#include "mysql.h"
int main()
{
MYSQL mysql;
mysql_init(&mysql);
if(!mysql_real_connect(&mysql, "localhost", "root", "admin", "demo", 3306, NULL, 0))
{
printf("\nconnect error!");
}
else
{
printf("\nconnect success!\n");
}
mysql_close(&mysql);
return 0;
}
    ÔÚÔ´ÎļþËùÔÚ·¾¶ÔËÐбàÒëÃüÁ
gcc -Iinclude -Llib main.c -llibmysql

    ¼´±àÒë³É¹¦¡£Êý¾Ý¿âÒàÁ¬½Ó³É¹¦¡£
    ²âÊÔ»·¾³£º
²Ù×÷ϵͳ£ºWindows XP Prefessional sp2
Êý¾Ý¿â°æ±¾£ºMySQL-5.0.22-commu


Ïà¹ØÎĵµ£º

mysqlÏà¹Ø

ÏÔʾ¡¢ÉèÖÃ×Ô¶¯Ìá½» show variable like 'autocommit'    set autocommit=1 or 0
ÉèÖÃÈÕÖ¾£º
ÔÚ/etc/mysql/my.cnfÖÐÉèÖÃÈçÏ¿ÉÔÙslow.logÖÐÊä³öÔËÐÐʱ¼ä³¬¹ýÒ»ÃëµÄsqlÓï¾ä
[mysqld]
log-slow-queries = /tmp/slow.log
long_query_time = 1
ÉèÖÃÈÕÖ¾Êä³öÔËÐг¬¹ý1ÃëµÄsqlÓï¾ä set global long_query_ti ......

²åÈëMYSQLÖÐÎÄÂÒÂë

1.½¨±í¹ý³ÌÈçÏÂ
create database  test default character set utf8 collate utf8_general_ci
use test;
create table devicedata
(
 ID int auto_increment PRIMARY key ,
 TimeStamp datetime,
 Device_Name varchar(100),
 Tag_Name varchar(100),
 Value varchar(50)
)
2 ......

ɾ³ýMYSQl BIN LOG ÈÕÖ¾

1.²é¿´µµ°¸
mysql> show binary logs;
+----------------+-----------+
| Log_name | File_size |
+----------------+-----------+
| ablelee.000001 | 150462942 |
| ablelee.000002 | 125 |
| ablelee.000003 | 106 |
+----------------+-----------+
2.ɾ³ýbin-log(ɾ³ýablelee.000003֮ǰµÄ¶øûÓаüº¬ablel ......

ÈçºÎÐÞ¸Ämysql rootÃÜÂë

1¡¢±à¼­MySQL(ºÍPHP´îÅäÖ®×î¼Ñ×éºÏ)ÅäÖÃÎļþ£º
windows»·¾³ÖУº%MySQL(ºÍPHP´îÅäÖ®×î¼Ñ×éºÏ)_installdir%\my.ini¡¡//Ò»°ãÔÚMySQL(ºÍPHP´îÅäÖ®×î¼Ñ×éºÏ)°²×°Ä¿Â¼ÏÂÓÐmy.ini¼´MySQL(ºÍPHP´îÅäÖ®×î¼Ñ×éºÏ)µÄÅäÖÃÎļþ¡£
linux»·¾³ÖУº/etc/my.cnf
ÔÚ[MySQL(ºÍPHP´îÅäÖ®×î¼Ñ×éºÏ)d]ÅäÖöÎÌí¼ÓÈçÏÂÒ»ÐУº
skip-grant-tables
......

ÓÅ»¯MySQLÊý¾Ý¿âÐÔÄܵļ¸¸öºÃ·½·¨

1¡¢Ñ¡È¡×îÊÊÓõÄ×Ö¶ÎÊôÐÔ
¡¡¡¡MySQL¿ÉÒԺܺõÄÖ§³Ö´óÊý¾ÝÁ¿µÄ´æÈ¡£¬µ«ÊÇÒ»°ã˵À´£¬Êý¾Ý¿âÖеıíԽС£¬ÔÚËüÉÏÃæÖ´ÐеIJéѯҲ¾Í»áÔ½¿ì¡£Òò´Ë£¬ÔÚ´´½¨±íµÄʱºò£¬ÎªÁË»ñµÃ¸üºÃµÄÐÔÄÜ£¬ÎÒÃÇ¿ÉÒÔ½«±íÖÐ×ֶεĿí¶ÈÉèµÃ¾¡¿ÉÄÜС¡£ÀýÈ磬ÔÚ¶¨ÒåÓÊÕþ±àÂëÕâ¸ö×Ö¶Îʱ£¬Èç¹û½«ÆäÉèÖÃΪCHAR(255),ÏÔÈ»¸øÊý¾Ý¿âÔö¼ÓÁ˲»±ØÒªµÄ¿Õ¼ä£¬ÉõÖÁÊ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ