MySQL¿ª·¢Ð¡½á
×î½üÕýÔÚ½øÐÐÒ»¸ö¶þ´Î¿ª·¢½Ó¿ÚµÄÏîÄ¿£¬ÔÚ¿ª·¢¹ý³ÌÖз¢ÏÖ£ºÎÒÃÇ֮ǰʹÓõĴ¦Àí¿Í»§¶ËºÍWEBÖ®¼ä±àÂë¼æÈÝÎÊÌâµÄ·½·¨ÊÇ´æÔÚÎÊÌâµÄ¡£ÓÉÓÚΪÁËÖ§³Ö¶àÓïÑÔ£¬Êý¾Ý¿â±íÖÐÀàÐÍΪvarcharµÄ×ֶΣ¬ËûÃǵÄ×Ö·û¼¯¶¼ÉèÖóÉÁËutf8¡£Ö®Ç°µÄ×ö·¨ÊÇ¿Í»§¶Ë½«×Ö·û´®µÄ±àÂë¸Ä³Éutf8±àÂ룬Ȼºó½«¸Ãutf8±àÂëµÄ×Ö·û´®Ö±½ÓдÈëÊý¾Ý¿â£¬ÕâÑùWEB(ʹÓÃPHPÓïÑÔ¿ª·¢µÄ)¾ÍÖ»ÐèÒª¼òµ¥µÄÐ޸ľÍÄÜÖ§³Ö¶à¹úÓïÑÔ£¬²¢ÇÒ»¹ÄܺͿͻ§¶ËµÄ¶àÓïÑÔ¼æÈÝ¡£ÓÉÓÚÎÒÃǵijÌÐòÔÚÁ¬½ÓÊý¾Ý¿âʱ£¬Ê¹ÓõÄÊÇĬÈϵÄ×Ö·û¼¯(latin1)£¬ËùÒÔµ±ÎÒÃÇÖ±½Ó²é¿´Êý¾Ý¿â±íÖеÄÊý¾Ýʱ£¬¿´µ½µÄ¾ÍÊÇòËÆÂÒÂëµÄÊý¾Ý(Õâ¾ÍÊÇ´æÈë×Ö·û´®µÄutf8±àÂë)¡£µ«µ±Ê¹ÓÃASP.NET¿ª·¢WEBʱ£¬Í¬ÑùµÄ×ö·¨¾ÍÎÞЧÁË¡£²éÔÄMySQLÊÖ²áºó£¬²ÂÏëÉèÖÃÁ¬½ÓµÄ×Ö·û¼¯¿ÉÄÜ¿ÉÒÔ½â¾öÕâ¸öÎÊÌâ¡£¾²âÊÔ£¬È·Êµ¿ÉÐС£ÕâÀï×ܽáһϽâ¾ö·½·¨£º
1.¸ü¸ÄÁ¬½ÓµÄ×Ö·û¼¯µÄ·½·¨
MySQLÌṩÁËÁ½ÖÖ·½·¨À´¸ü¸ÄÁ¬½ÓµÄ×Ö·û¼¯£¬ÕâÁ½ÖÖ·½·¨·Ö±ðÊÇ£º
(1)SET NAMESÓï¾ä;
(2)APIº¯Êýmysql_set_character_set()
MySQLÊÖ²áÖн¨Òé×îºÃʹÓÃ(2)À´ÐÞ¸ÄÁ¬½ÓµÄ×Ö·û¼¯£¬ÒòΪ“Èç¹ûÐèÒª¸ü¸ÄÁ¬½ÓµÄ×Ö·û¼¯£¬Ó¦¸ÃʹÓÃmysql_set_character_setº¯Êý£¬¶ø²»ÊÇÖ´ÐÐSET NAMESÓï¾ä¡£mysql_set_character_setµÄ¹¤×÷·½Ê½ÀàËÆÓÚSET NAMES£¬µ«Ëü»¹ÄÜÓ°Ïìmysql_real_escape_stringËùʹÓõÄ×Ö·û¼¯£¬¶øSET NAMES²»ÄÜ¡£”
2.Ö´ÐÐmysql²åÈëÓï¾äʱ£¬·µ»Ø1366µÄ´íÎóµÄ½â¾ö°ì·¨
µ¼ÖÂÕâ¸öÎÊÌâµÄÔÒòÊÇ£ºµ±½«mysqlµÄÁ¬½ÓµÄ×Ö·û¼¯¸ÄΪutf8ºó£¬Èç¹û²åÈëÊý¾Ý¿â±íÖеÄ×Ö·û´®²»ÊÇutf8±àÂëµÄ´®£¬Ôò»á³öÏÖÕâ¸ö´íÎó¡£ÔÚ½«Á¬½Ó¸ü¸ÄΪutf8ºó£¬¶Á³öÀ´µÄ×Ö·û´®Êý¾ÝÒ²ÊÇutf8±àÂëµÄ¡£ËùÒÔÎÒÐèÒª½«×Ö·û´®ÔÚutf8ºÍansiÖ®¼äÏ໥ת»»£¬×ª»»µÄÖ÷Òª´úÂëÈçÏ£º
void AnsiToUtf8(const char* szAnsi, char* szUtf8, int nSize)
{
int nChar = MultiByteToWideChar(CP_ACP, 0, szAnsi, -1, NULL, 0);
if (nChar > 0)
{
wchar_t* pBufw = new wchar_t[nChar];
MultiByteToWideChar(CP_ACP, 0, szAnsi, -1, pBufw, nChar);
WideCharToMultiByte(CP_UTF8, 0, pBufw, -1, szUtf8, nSize, NULL, NULL);
delete[] pBufw;
}
}
void Utf8ToAnsi(const char* szUtf8, char* szAnsi, int nSize)
{
int nChar = MultiByteToWideChar(CP_UTF8, 0, szUtf8, -1, NULL, 0);
if (nChar > 0)
{
wchar_t* pBufw = new wchar_t[nChar];
MultiByteToWideChar(CP_UTF8,
Ïà¹ØÎĵµ£º
Java´úÂë
mysql> select version(),current_date;
²éѯmysqlµÄ°æ±¾ºÅ ºÍ ÈÕÆÚ
mysql> select version();
²éѯmysqlµÄ°æ±¾ºÅ
select now();
²éѯµ±Ç°ÈÕÆÚºÍ׼ȷµÄʱ¼ä
Java ......
À´×Ô: http://www.phpv.net/html/1666.html
#BEGIN CONFIG INFO
#DESCR: 4GB RAM, ֻʹÓÃInnoDB, ACID, ÉÙÁ¿µÄÁ¬½Ó, ¶ÓÁиºÔØ´ó
#TYPE: SYSTEM
#END CONFIG INFO
#
# ´ËmysqlÅäÖÃÎļþÀý×ÓÕë¶Ô4GÄÚ´æ
# Ö÷ҪʹÓÃINNODB
#´¦Àí¸´ÔÓ¶ÓÁв¢ÇÒÁ¬½ÓÊýÁ¿½ÏÉÙµÄmysql·þÎñÆ÷
#
# ½«´ËÎļþ¸´ÖƵ½/etc/my.cnf ×÷Ϊȫ¾ÖÉèÖÃ, ......
ÒÔÏÂÃüÁî¿ÉÒÔÔÚÈκÎÒѾÁ¬½ÓÉÏMYSQL·þÎñÆ÷µÄ¿Í»§¶ËÉÏÖ´ÐС£
show full processlist ;
kill 57725;#ɱµôÉÏÃæ²éµ½µÄij¸öµ¼ÖÂ×èÈûµÄÁ¬½Ó
SELECT @@profiling;
SET profiling = 1;
SHOW PROFILES;
SHOW PROFILE for QUERY 1;
#ϵͳÉèÖÃ
show variables like '%key%';
show variables like '%key%';
show variables l ......
×÷ÕߣºÀÏÍõ
MySQL5.X¶¼ÒѾ·¢²¼ºÃ¾ÃÁË£¬µ«ÊÇ»¹ÓкܶàÈËÈÏΪMySQLÊDz»Ö§³ÖÊÂÎñ´¦ÀíµÄ£¬Õâ²»µÃ²»¹ÖËûÃÇÊǹª¹ÑÎŵģ¬Æäʵ£¬Ö»ÒªÄãµÄMySQL°æ±¾Ö§³ÖBDB»òInnoDB±íÀàÐÍ£¬ÄÇôÄãµÄMySQL¾Í¾ßÓÐÊÂÎñ´¦ÀíµÄÄÜÁ¦¡£ÕâÀïÃ棬ÓÖÒÔInnoDB±íÀàÐÍÓõÄ×î¶à£¬ËäÈ»ºóÀ´·¢ÉúÁËÖîÈçOracleÊÕ¹ºInnoDBµÈÁîMySQL²»Ë¬µÄÊÂÇ飬µ«ÄÇЩÉÌÒµÉϵĶ·ÕùÓ ......