Linux C MySQLÊý¾Ý¿âº¯Êý
1. ³õʼ»¯Ò»¸öÁ¬½Ó¾ä±ú
MYSQL *mysql_init(MYSQL *);
ÕýÈ·£º·µ»ØÒ»¸öÖ¸ÏòзÖÅäµÄÁ´½Ó¾ä±ú½á¹¹µÄÖ¸Õë
´íÎó£ºNULL
×¢£º¸Ãº¯ÊýµÄ´«Èë²ÎÊýͨ³£ÎªNULL¼´¿É¡£
2. ½¨Á¢ÎïÀíÁ¬½Ó
MYSQL *mysql_real_connect(MYSQL *connection,
const char *server_host,
const char *sql_user_name,
const char *sql_password,
const char *db_name,
unsigned int port_number,
const char *unix_socket_name,
unsigned int flags);
ÆäÖÐconnection²ÎÊýΪͨ¹ýmysql_initº¯Êý´´½¨µÄ¾ä±ú£¬server_host²ÎÊý¿ÉΪÖ÷»úÃû»òIPÖµ£¬Èç¹ûÁ¬µ½±¾»ú£¬ÎÒÃǽö½öÖ»ÐèÖ¸¶¨“localhost”¼´¿É¡£sql_user_nameºÍsql_password¼´Îª·ÃÎÊÊý¾Ý¿âµÄÓû§ÃûºÍÃÜÂ룬Èç¹ûsql_user_nameΪ¿Õ£¬ÄÇôĬÈÏΪµ±Ç°Linux userµÄÓû§Ãû£¬Èç¹ûsql_passwordΪ¿Õ£¬ÄÇôֻÄÜ·ÃÎʲ»ÐèÒªÃÜÂëµÄÊý¾Ý¡£ÃÜÂëÔÚ¾ÍøÂç´«Êä֮ǰ¶¼¾¹ý¼ÓÃÜ´¦Àí¡£Í¨³£Çé¿öÏ£¬Èç¹ûÄãûÓиıäMySQLµÄĬÈÏ°²×°£¬port_numberºÍ*unix_socket_nameµÄÖµ·Ö±ðΪ0ºÍNULL¼´¿É£¬ËûÃÇĬÈÏΪµ±Ç°ÏàÓ¦Öµ¡£flags²ÎÊýÔÊÐíÎÒÃǸı䵱ǰʹÓÃÐÒéµÄÌØÐÔ£¬Ä¬ÈÏÇé¿öÏ£¬ÖÃ0¼´¿É¡£
Èç¹ûÁ¬½Ó²»³É¹¦£¬¸Ãº¯Êý·µ»ØNULL
3. ¶Ï¿ªÁ¬½Ó
void mysql_close(MYSQL *connection);
ʹÓøú¯Êý¿ÉÒԶϿªÖ¸¶¨µÄÁ´½Ó¡£²»Èò»ÐèÒªµÄÁ¬½Ó¶Ï¿ª»áÀË·Ñ×ÊÔ´£¬µ«ÖØн¨Á¢Á¬½ÓÐèÒª¶îÍ⿪Ïú£¬ÔÚʵ¼Ê¹¤×÷ÖÐÎÒÃǿɸù¾ÝÐèҪȨºâ¡£
4. Ñ¡ÏîÉèÖÃ
int mysql_options(MYSQL *connection, enum option_to_set,
const char *argument);
¸Ãº¯Êý¿ÉÓÃÔÚmysql_initºÍmysql_real_connectÖ®¼äÀ´ÉèÖÃһЩÁ¬½ÓÑ¡Ïoption_to_set²ÎÊýÈçMYSQL_OPT_CONNECT_TIMEOUTÓÃÀ´ÉèÖÃÁ¬½Ó³¬Ê±µÄʱ¼ä(Ãë)£¬MYSQL_OPT_COMPRESS±íʾÔÚÍøÂç´«ÊäÖжÔÊý¾Ý½øÐÐѹËõ£¬¶øMYSQL_INIT_COMMANDÖ¸¶¨Ã¿µ±Á¬½Ó½¨Á¢Ê±ÓÃÀ´·¢Ë͵ÄÃüÁî¡£
º¯Êý³É¹¦Ê±·µ»Ø0£¬ÒòΪ¸Ãº¯Êý½ö½öÓÃÀ´ÉèÖÃÑ¡ÏËùÒÔʧ°ÜÒâζ×ÅʹÓÃÁËÎÞЧµÄÑ¡Ïî¡£´ËÍ⣬¸Ãº¯Êýÿ´ÎÖ»ÄÜÉèÖÃÒ»ÖÖÑ¡ÏËùÒÔÿÉèÖÃÒ»¸öÑ¡Ïî¾Í±ØÐëµ÷Óøú¯ÊýÒ»´Î¡£
¾ÙÀý£º
unsigned int timeout = 7;
connection = mysql_init(NULL);
Ïà¹ØÎĵµ£º
±¸×¢£ºÈç¹ûÄãÓÐʱ¼äÄãÓ¦¸ÃÔĶÁÕâ¸ö±¸×¢£¬Èç¹ûûÓÐʱ¼äÄã¸üÒªÔĶÁÒÔϱ¸×¢¡£ ÔÚÍøÂçÉÏÕÒÁ˺ܶàÏà¹Ø±¸·ÝºÍ»¹ÔµÄ½Ì³Ì£¬´ó¶à¶¼ÊÇ»¥Ïà³Ï®£¬°´ÕÕËûÃǵĽ̳ÌÄܹ»³É¹¦±¸·Ý£¬»¹Ô¾ÍºÜÈÃÈ˾¾ÐÄÁË¡£Ì¸Ì¸Ë¼Â·ºÍ×¢Òâµã°É¡£ Ê×ÏÈ£¬µÚÒ»²½²»ÓÃ˵£¬¿Ï¶¨ÊDZ¸·ÝÊý¾Ý¿â¡£×î¼òµ¥£¬´ò¿ª¹ÜÀí½ÚµãµÄndb_mgm¿ØÖÆ̨£¬ÊäÈëstart backup backupID£¨ ......
ϵͳ»·¾³£ºrhel5 (×îС»¯°²×°£¬Ö»°²×°vi¹¤¾ß) Äںˣº2.6.18-8.el5 1¡¢ ÏÂÔرàÒë°²×° #cd /usr/local/src/tarbag #wget http://mysql.byungsoo.net/Downloads/MySQL-5.1/mysql-5.1.38.tar.gz //ÏÂÔØ5.1.38 #tar xzvf mysql-5.1.38.tar.gz -C ../software/ #cd ../software/mysql-5.1.38 #./configure --prefix=/usr ......
×¢: ´ÓMySQL´Ó·þÎñÆ÷µÄ°æ±¾²»ÄÜСÓÚÖ÷·þÎñÆ÷µÄ°æ±¾ ʵÑé»·¾³ Master Mysql·þÎñÆ÷°æ±¾5.1.36,IP:192.168.128.130 Slave Mysql·þÎñÆ÷°æ±¾5.1.36,IP:192.168.128.132 Ò». MySQLÖ÷·þÎñÆ÷ÅäÖà 1.½¨Á¢ÊÚȨÓû§ Ó÷¨:grant replication slave on *.* to ¡®Óû§Ãû¡¯@'Ö÷»ú¡¯ identified by ¡®ÃÜÂ롯; mysql>grant replicatio ......
ÁªºÏMySQL Proxy ºÍMySQL Cluster£¬¹¹½¨¸ßÐÔÄÜÊý¾Ý¿â
ÔÎÄ£ºhttp://blogs.mysql.com/kaj/2007/12/10/combining-mysql-proxy-with-mysql-cluster/
²»¾ÃÇ°£¬ÎÒºÍStewart Smith, Vinay Joosery, Monty Taylor ÒÔ¼°ÆäËûµÄmysqlʹÓÃÕߣ¨ËûÃDZÈÎÒ¸üÊìϤMySQL Cluster £©Õ¹¿ªÁËÒ»´ÎÌÖÂÛ£ ......
½ñÌìÓÐÅóÓÑÎÊÆð´ËÀàÓï¾äµÄÓÅ»¯£¬ÎÒ´óÖ¸øËû½éÉÜÁËÏ´ÓSQL½Ç¶È×ö¼òµ¥µÄÓÅ»¯£¬ÖÁÓÚÓ¦ÓóÌÐò·½ÃæµÄ¿¼ÂÇÔÛÔÝʱ²»¿¼ÂÇ¡£
ÏÂÃæÎÒÀ´¾ÙÒ»¸ö
¼òµ¥µÄÀý×Ó¡£
¿¼ÂÇÈçÏÂ
±í½á¹¹£º
/*DDL Information
For - t_girl.t_page_sample*/
----------------------------------------------
Table ......