java mysql ºº×Ö´æÈëʱÂÒÂë
´ÓÍøÂçÕª³µ½µÄ½â¾ö·½·¨——
½â¾ö·½·¨¶þ£º
Á¬½Ómysqlʱ(ÎÞÂÛÔÚ´Ómysql¶Á»¹ÊÇÈ¡Êý¾ÝµÄÇé¿ö)£¬Ö¸¶¨Ê¹ÓõıàÂ뷽ʽΪutf-8£¬¾ßÌå´úÂëÈçÏÂ
//×°ÔØmysql-jdbcÇý¶¯
Class.forName("com.mysql.jdbc.Driver").newInstance();
//Á¬½ÓÊý¾Ý¿â
Connection sqlCon = DriverManager.getConnection( "jdbc:mysql://localhost:3306/javatest?user=root&password=admin&useUnicode=true&characterEncoding=utf-8 " );
ÎÒÊÇÓÃÕâ¸ö·½·¨½â¾öµÄ¡£
ÔÚÅäÖÃÎļþÖиÄΪ
url="jdbc:mysql://127.0.0.1/elearning?useUnicode=true&characterEncoding=utf-8"
³ö´í£¬ºó¸ÄΪurl="jdbc:mysql://127.0.0.1/elearning?useUnicode=true&characterEncoding=utf-8"
³É¹¦
Ïà¹ØÎĵµ£º
create database testdb; /* ´´½¨Êý¾Ý¿â */
use testdb; /* ´ò¿ªÊý¾Ý¿â */
/*grant ÆÕͨÊý¾ÝÓû§£¬²éѯ¡¢²åÈë¡¢¸üС¢É¾³ý Êý¾Ý¿âÖÐËùÓбíÊý¾ÝµÄȨÀû*/
grant select,insert,update,delete on testdb.* to common_user@'%';
grant select,insert,update,delete on testdb.* to common_user@'localhost'; ......
MySQLΪÎÒÃÇÌṩÁ˺ܶà±íÀàÐ͹©Ñ¡Ôñ£¬ÓÐMyISAM¡¢ISAM¡¢HEAP¡¢BerkeleyDB¡¢InnoDB£¬MERGE±íÀàÐÍÿһÖÖ±íÀàÐͶ¼ÓÐÆä×Ô¼ºµÄÊôÐÔºÍÓŵ㡣ÏÂÃæÎÒÃÇÀ´¼òµ¥µÄÌÖÂÛһϡ£
MyISAM±íÀàÐÍ£º
MyISAM
±í(TYPE=MYISAM)ÊÇISAMÀàÐ͵ÄÒ»ÖÖÑÓÉ죬¾ßÓкܶàÓÅ»¯ºÍÔöÇ¿µÄÌØÐÔ¡£ÊÇMySQLµÄĬÈϱíÀàÐÍ¡£MyISAMÓÅ»¯ÁËѹËõ±ÈÀýºÍËٶȣ¬²¢ÇÒ
¿ÉÒ& ......
Ê×ÏÈÉèÖÃMySQLÖ÷·þÎñÆ÷£º
ÔÚÖ÷·þÎñÆ÷ÉÏΪ´Ó·þÎñÆ÷½¨Á¢Ò»¸öÓû§£º
grant replication slave on *.* to 'Óû§Ãû'@'Ö÷»ú' identified by 'ÃÜÂë';
Èç¹ûʹÓõÄÊÇMySQL 4.0.2֮ǰµÄ°æ±¾£¬ÔòÓÃfileȨÏÞÀ´´úÌæreplication slave
±à¼Ö÷·þÎñÆ÷µÄÅäÖÃÎļþ£º/etc/my.cnf
server-id=1
log-bin
binlog-do-db=ÐèÒª¸´ÖƵÄÊý¾Ý¿âÃû£ ......
MySQLµ¼Èëµ¼³öÃüÁî
1.µ¼³öÕû¸öÊý¾Ý¿â
¡¡¡¡mysqldump -u Óû§Ãû -p Êý¾Ý¿âÃû > µ¼³öµÄÎļþÃû
¡¡¡¡mysqldump -u wcnc -p smgp_apps_wcnc > wcnc.sql
2.µ¼³öÒ»¸ö±í
¡¡¡¡mysqldump -u Óû§Ãû -p Êý¾Ý¿âÃû ±íÃû> µ¼³öµÄÎļþÃû
¡¡¡¡mysqldump -u wcnc -p smgp_apps_wcnc users> wcnc_users.sql
3.µ¼³öÒ ......
ÂÒÂëÕæÊǸöÁîÈËÌÖÑáµÄÎÊÌâ~
¸Õ²ÅÖÕÓÚ°ÑMySQLÓëJSP½»»¥µÄÂÒÂëÎÊÌâ½â¾öÁË¡£
°ì·¨ÈçÏ£º
1.ÔÚurl´¦¼ÓÉϾä×Ó "&useUnicode=true&characterEncoding=GBK" £»
2.ÎÒÓÃNavicat Lite¿ÉÊÓ»¯¹¤¾ß´´½¨MySQLÊý¾Ý¿âʱ£¬¿ÉÑ¡¶¨Êý¾Ý¿â±àÂ룬ҲÊÇ GBK £»
3.Ò³ÃæµÄ±àÂë¿ÉÒÔÑ¡GBKÒÔÍâµÄ±àÂ뷽ʽ£¬ÈçUTF-8¡£Èô²Ù×÷Ò³ÃæµÄ±àÂëÊÇUTF- ......