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

Linux»·¾³MySQLµÄC±à³ÌÆð²½

Ê×ÏȰ²×°±ØÐèµÄ¿ª·¢
°ü
sudo apt-get install gcc g++ libgcc1 libg++ make gdb
°²×°MYSQLµÄCÓïÑÔ¿ª·¢°ü
sudo apt-get install libmysql++-dev libmysql++2c2a libmysqlclient15-dev libmysqlclient15off
°ÑlibÎļþ¿½±´µ½¹«ÓÃ
sudo cp /usr/lib/mysql/* /usr/lib/
½¨Á¢Ò»¸öÐÂÎļþtest.cpp
vim test.cpp
ÊäÈëÄÚÈÝ
#include
#include
#include "/usr/include/mysql/mysql.h"
int main() {
MYSQL mysql;
mysql_init(&mysql);
}
ctrl+O±£´æctrl+xÍ˳ö¡£
È»ºó±àÒë
g++ -lmysqlclient test.cpp -o test
ÔËÐÐ
./test
Èç¹ûʲô¶¼Ã»Ìáʾ£¬Ã»´íÎ󣬾Í˵Ã÷³É¹¦ÁË¡£
 
ÏÂÃæÊÇ×Ô¼ºÐ´µÄÒ»¸öС³ÌÐò£º²éѯmysql½øÐÐÈõµã¹ØÁª¡£
#include
#include
#include
#include
#include "/usr/include/mysql/mysql.h"
void asso_1(){
MYSQL mysql_conn; /* Mysql connection handle */
MYSQL_RES *mysql_result1, *mysql_result2, *mysql_result3; /* Result handle */
MYSQL_ROW mysql_row1, mysql_row2, mysql_row3; /* Row data */
int f1, f2, num_row1, num_col1, num_row2, num_col2;
printf("Start association analyse type 1: Weekness association\n");
int i;
for (i = 0; i<20; i++) printf("# ");
printf("\n");
if (mysql_init(&mysql_conn) == NULL) printf("Initialization fails\n");
if
(mysql_real_connect(&mysql_conn, "localhost", "root", "123456",
"test", 3306, NULL, 0) == NULL) printf("Connection fails\n");
if (mysql_query(&mysql_conn, "SELECT scid,aid,proto,dip,dport from `scan_table`") != 0)
printf("Query fails\n");
mysql_result1 = mysql_store_result(&mysql_conn);
num_row1 = mysql_num_rows(mysql_result1); /* Get the no. of row */
num_col1 = mysql_num_fields(mysql_result1); /* Get the no. of column */
for (f1 = 0; f1 < num_row1; f1++) {
mysql_row1 = mysql_fetch_row(mysql_result1); /* Get a row */
printf ("%s %s %s %s\n",mysql_row1[1],mysql_row1[2],mysql_row1[3],mysql_row1[4]);
char *str;
str = (char *)malloc(1024);
strcpy(s


Ïà¹ØÎĵµ£º

ubuntu8.04.2ÏÂApache+Resin+Mysql°²×°+ÐéÄâÖ÷»úÅäÖÃ

 Ò» Apache°²×°
# tar zxvf httpd-2.2.14.tar.gz(½âѹ)
# cd httpd-2.2.14(½øÈë½âѹºóµÄĿ¼)
# ./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=all
  (ÃüÁî#./configure --help¿ÉÒԲ鿴configureµÄÅäÖòÎÊý
  --prefix=°²×°Â·¾¶
  --enable-so //´ò¿ª DSO Ö§³ÖµÄ a ......

MySQL µÄ×Ô¶¯¶Ï¿ªÁ¬½ÓÎÊÌâ

 MySQL »á×Ô¶¯¶Ï¿ª IDLE ʱ¼ä³¬¹ý 8 СʱµÄÊý¾Ý¿âÁ¬½Ó£¬´Ó¶øµ¼ÖÂһЩ»ùÓÚÊý¾Ý¿âÁ¬½ÓµÄÓ¦ÓóÌÐò£¬ÌرðÊÇ WEB Ó¦ÓóÌÐò³ö´í¡£
ÓÐÁ½¸ö°ì·¨¿ÉÒÔ½â¾öÕâ¸öÎÊÌ⣺
µÚÒ»¸ö°ì·¨ÊÇÐÞ¸Ä MySQL µÄÅäÖòÎÊý¡£Õâ¸ö²ÎÊýµÄÃû³ÆÊÇ wait_timeout
£¬ÆäĬÈÏֵΪ 28800(µ¥Î»Ãë)£¬¸ÕºÃ¾ÍÊÇ 8 Сʱ¡£ÆäÒâÒåΪ¹Ø±ÕÒ»¸öÁ¬½Ó֮ǰÔÚÕâ¸öÁ¬½ÓÉϵ ......

mysql µÄһЩ³£ÓÃÃüÁî

 ÔÊÐíËùÓÐÖ÷»úÔ¶³Ì·ÃÎÊ
GRANT ALL PRIVILEGES ON *.* TO 'dba'@'%' IDENTIFIED BY 'dbapassword' WITH GRANT OPTION;
Ö¸¶¨Ö÷»ú¿ÉÔ¶³Ì
GRANT ALL PRIVILEGES ON *.* TO 'dba'@'192.168.0.100' IDENTIFIED BY 'dbapassword' WITH GRANT OPTION;
Ö¸¶¨È¨ÏÞ¿ªÔ¶³Ì
grant select,insert,update,delete on test.* to db ......

MYSQl left joinÁªºÏ²éѯЧÂÊ·ÖÎö

user±í:
id | name
———
1 | libk
2 | zyfon
3 | daodao
user_action±í:
user_id | action
—————
1 | jump
1 | kick
1 | jump
2 | run
4 | swim
sql:
select id, name, action from user as u
left join user_action a on u.id = a.user_id
result:
id | ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ