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

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);


Ïà¹ØÎĵµ£º

mysql ×ÔÔöÁеĴ´½¨

1.½¨±íʱ¾Í´´½¨×ÔÔöÁУº
create table test
(
 id int auto_increment primary key,
 name varchar(20) not null,
 password varchar(20) not null
);
insert into test values(null,'aa','aa');
insert into test values(null,'bb','bb');
×¢Ò⣺
      ²åÈëÓï¾äʱ£¬×Ô ......

ÁªºÏMySQL Proxy ºÍMySQL Cluster£¬¹¹½¨¸ßÐÔÄÜÊý¾Ý¿â


ÁªºÏ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 £©Õ¹¿ªÁËÒ»´ÎÌÖÂÛ£ ......

mysql ³£¼û´íÎ󼯺Ï


 
1£º Can’t connect to [local] MySQL server´íÎó
Ò»¸öMySQL¿Í»§¿ÉÒÔÁ½ÖÖ²»Í¬µÄ·½Ê½Á¬½Ómysqld·þÎñÆ÷£ºUnixÌ×½Ó×Ö£¬Ëüͨ¹ýÔÚÎļþϵͳÖеÄÒ»¸öÎļþ(ȱʡ“/tmp /mysqld.sock”)½øÐÐÁ¬½Ó£»»òTCP/IP£¬Ëüͨ¹ýÒ»¸ö¶Ë¿ÚºÅÁ¬½Ó¡£UnixÌ×½Ó×Ö±ÈTCP/IP¸ü¿ì£¬µ«ÊÇÖ»ÓÐÓÃÔÚÁ¬½Óͬһ̨¼ÆËã»úÉϵķþÎñÆ÷¡£Èç¹ûÄ ......

Mysql·ÖÇø


http://dev.mysql.com/doc/refman/5.1/zh/partitioning.html
²é¿´ÊÇ·ñÖ§³Ö·ÖÇø£ºSHOW VARIABLES LIKE '%partition%';
·ÖÇøÓï¾äCREATE TABLE ti (id INT, amount DECIMAL(7,2), tr_date DATE)
ENGINE=INNODB
PARTITION BY HASH(MONTH(tr_date))
PARTITIONS 6; 
---------------------------------- ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ