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

linux c++Á¬½ÓmysqlʾÀý

 
¡¡±àÒëºÍÁ¬½Ó³ÌÐò
¡¡¡¡MySQLÖÐÓÐÒ»¸öÌØÊâµÄ½Å±¾,½Ð×ömysql_config. Ëü»áΪÄã±àÒëMySQL¿Í»§¶Ë,²¢Á¬½Óµ½MySQL·þÎñÆ÷ÌṩÓÐÓõÄÐÅÏ¢.ÄãÐèҪʹÓÃÏÂÃæÁ½¸öÑ¡Ïî.
¡¡¡¡1. --libs Ñ¡Ïî - Á¬½ÓMySQL¿Í»§¶Ëº¯Êý¿âËùÐèÒªµÄ¿âºÍÑ¡Ïî.
¡¡¡¡$ mysql_config --libs
¡¡¡¡2. --cflags Ñ¡Ïî - ʹÓñØÒªµÄincludeÎļþµÄÑ¡ÏîµÈµÈ.
¡¡¡¡$ mysql_config --cflags
¡¡¡¡ÄãÐèÒª½«ÉÏÃæÁ½¸öÑ¡Ïî¼ÓÈëµ½¶ÔÔ´ÎļþµÄ±àÒëÃüÁîÖÐ. ËùÒÔ,Òª±àÒëÉÏÃæµÄ³ÌÐò,ҪʹÓÃÏÂÃæµÄÃüÁî:
¡¡¡¡$ g++ -o output-file $(mysql_config --cflags) test.c $(mysql_config --libs)
¡¡¡¡Ö´ÐбàÒëºóµÄ³ÌÐò:
¡¡¡¡$ ./output.file
#include <mysql.h>
#include <stdlib.h>
#include <stdio.h>
static char *server_args[] =
{
"this_program", /* this string is not used */
"--datadir=.",
"--key_buffer_size=32M"
};
static char *server_groups[] =
{
"embedded",
"server",
"this_program_SERVER",
(char *)NULL
};
int main(void)
{
if (mysql_server_init(sizeof(server_args) / sizeof(char *),
server_args, server_groups))
exit(1);
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
char *server = "localhost";
char *user = "admin";
char *password = "metrics"; /* ´Ë´¦¸Ä³ÉÄãµÄÃÜÂë */
char *database = "test";
conn = mysql_init(NULL);
/* Connect to database */
if (!mysql_real_connect(conn, server,
user, password, database, 0, NULL, 0))
{
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}
/* send SQL query */
if (mysql_query(conn, "show tables"))
{
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}
res = mysql_use_result(conn);
//utput table name */
printf("MySQL Tables in mysql database:\n");
while ((row = mysql_fetch_row(res)) != NULL)
printf("%s \n", row[0]);


Ïà¹ØÎĵµ£º

×î³£ÓÃLINUX³£ÓÃÃüÁî

 LINUX³£ÓÃÃüÁ»ù´¡£©
1. man ¶ÔÄãÊìϤ»ò²»ÊìϤµÄÃüÁîÌṩ°ïÖú½âÊÍ
eg:man ls ¾Í¿ÉÒԲ鿴lsÏà¹ØµÄÓ÷¨
×¢£º°´q¼ü»òÕßctrl+cÍ˳ö£¬ÔÚlinuxÏ¿ÉÒÔʹÓÃctrl+cÖÕÖ¹µ±Ç°³ÌÐòÔËÐС£
2. ls ²é¿´Ä¿Â¼»òÕßÎļþµÄÊô*£¬ÁоٳöÈÎһĿ¼ÏÂÃæµÄÎļþ
eg: ls /usr/man
ls -l
a.d±íʾĿ¼(directory)£¬Èç¹ûÊÇÒ»¸ö"-"±íʾÊÇÎļþ ......

Enable/Disable Linux mousekeys

 
gcc mousekey.c -lX11 -IX11
´ò¿ªmousekeysÔËÐÐ./a.out
¹Ø±ÕmousekeysÔËÐÐ./a.out 1,ÕâÀïÔÚa.outºóÃæËæ±ã¼ÓÒ»¸ö²ÎÊý¾Í¿ÉÒÔÁË£¬ÒòΪÅжÏÌõ¼þΪ if(argc < 2)
/*********source code***************/
#include <stdio.h>
#include <string.h>
#include <X11/Xlib.h>
#include <X ......

ÔõÑù±àдLinux shell script(Ò»)

 ½üÀ´ÕýÔÚѧϰLinux shell script£¬Ö÷ÒªÊÇѧϰLinux Shell Scripting Tutorial (LSST) v1.05r3µÄ¼¸¸öÕ½ڣ¬µ«ÒòΪÊÇÓ¢ÎĵÄËùÒÔÕâÀï°ÑËü·­ÒëÏ£¬Ò²ÊÇ×Ô¼º¼ÓÉîÓ¡Ï󡣺ÃÁËÖ±½Ó½øÈëÖ÷Ìâ¡£
1.How to write shell script £¿
a.Ê×ÏÈÓÃÈκεıàÒëÆ÷£¨vi,vim,kwrite,....£©±àдһ¸öshell script£»
b.È»ºó°´ÕÕÏÂÃæµÄ·½·¨¸øÄã± ......

Linux 2.6 ÖеÄÎļþËø

»Æ Ïþ³¿
(huangxc@cn.ibm.com
), Èí¼þ¹¤³Ìʦ, IBM
·ë Èñ
(fengrui@cn.ibm.com
), Èí¼þ¹¤³Ìʦ, IBM
2008 Äê 7 ÔÂ 03 ÈÕ
±¾ÎĵÄÄ¿µÄÊÇÏë°ïÖú¶ÁÕßÀíÇå Linux 2.6ÖÐÎļþËøµÄ¸ÅÄîÒÔ¼°
Linux 2.6
¶¼ÌṩÁ˺ÎÖÖÊý¾Ý½á¹¹ÒÔ¼°¹Ø¼üµÄϵͳµ÷ÓÃÀ´ÊµÏÖÎļþËø£¬´Ó¶ø¿ÉÒÔ°ïÖú¶ÁÕ߸üºÃµØʹÓÃÎļþËøÀ´½â¾ö¶à¸ö½ø³Ì¶ÁÈ¡Í ......

Linux ÊÍ·ÅÄÚ´æ·½·¨


Linux ÊÍ·ÅÄÚ´æ·½·¨
ÏÈ¿´¿´ÄÚ´æʹÓÃ×´¿ö
[root@node1 ~]# free -m
total used free shared buffers cached
Mem: 8004 6557 1446 0 163 5630
-/+ buffers/cache: 763 7240
Swap: 1983 0 1983
°ÑÄÚ´æÀïµÄÊý¾ÝÔÝʱдµ½Ó²ÅÌÀï
[root@node1 ~]# sync
ÐÞ¸Ä /proc/sys/vm/drop_cachesÎļþ
[root@node1 ~]# echo 3 > ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ