Linux mysql°²×°ÐÞ¸ÄrootÃÜÂë·þÎñ
ÔÚÏò´ó¼ÒÏêϸ½éÉÜLinux mysql֮ǰ£¬Ê×ÏÈÈôó¼ÒÁ˽âÏÂLinux mysql£¬È»ºóÈ«Ãæ½éÉÜLinux mysql£¬Ï£Íû¶Ô´ó¼ÒÓÐÓá£
1. Linux mysql°²×°£º
$ yum install mysql-server
2. Linux mysqlÐÞ¸ÄrootÃÜÂ룺
$ mysqladmin -u root password
your_new_passwd
3. Æô¶¯Linux mysql·þÎñ
$ /etc/init.d/mysqld start
4. Ìí¼ÓΪϵͳ·þÎñ²¢ËæÖ®×Ô¶¯Æô¶¯£º
$ chkconfig --level 2345 mysqld on
5. Ð޸ķÀ»ðǽ£¬¿ªÆô3306¶Ë¿Ú£¬Ê¹µÃ¿ÉÒÔ½øÐÐÔ¶³Ì·ÃÎÊ£º
System->Administration->Firewall->Other
ports£¬Ìí¼Ó3306¶Ë¿Ú£¬Ò»¶¨Òª°ÑtcpºÍudp¶¼¼ÓÉÏ£¡
Æä±¾ÖÊÊÇÐÞ¸ÄÁË/etc/sysconfig/iptablesÎļþ£¬Ò²¿ÉÖ±½Ó½øÐÐÐ޸ģ¬°´ÕÕÈçϸñʽ£º
-A INPUT -m
state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -m
state --state NEW -m tcp -p udp --dport 3306 -j ACCEPT
6. mysqlĬÈϵÄrootÓû§ÊDz»ÄÜÔ¶³Ì·ÃÎʵģ¬ÐèҪΪLinux
mysqlÖÐÌí¼ÓÒ»¸ö¿ÉÒÔÔ¶³Ì·ÃÎʵÄÓû§£¬Ê×ÏÈÒÔrootÓû§µÇ¼Linux mysql£¬È»ºóÔö¼ÓÒ»¸öÓû§£º
GRANT ALL ON *.*
TO your_username@'your_host_name_or_ip_address' IDENTIFIED BY
'your_password'
ÕâÀïµÄALL±íʾ£¬ËùÓÐÈκÎȨÏÞ£¨°üÀ¨Ôöɾ¸ÄµÈ£©£¬*.*±íʾÈκÎÊý¾Ý¿âÖеÄÈÎºÎ±í£¬Ò²¿ÉÖ¸¶¨³ÉLinux
mysqlÖеÄij¸öÊý¾Ý¿âÉõÖÁij¸ö±í£¬¸ÃÓû§µÇ¼ºóÖ»ÄܶԸÃÊý¾Ý¿â½øÐиոո³ÓèµÄ²Ù×÷¡£your_host_name_or_ip_addressÊÇÖ¸¹æ
¶¨ÄãÖ»ÄÜÔÚͨ¹ý¸ÃipµØÖ·Ô¶³Ì·ÃÎÊ£¬Èç¹ûÖ¸¶¨ÈÎÒâµØÖ·¾ù¿É·ÃÎÊ£¬Ôò¿ÉÓÃͨÅä·û%´úÌæ¡£
±ÈÈ磺GRANT insert ON test.* IDENTIFIED BY
'test'ËüµÄº¬ÒåÊÇ£¬Óû§¿ÉÔÚÈÎÒâIPµØַͨ¹ýÓû§Ãûtest£¬ÃÜÂëtestµÇ¼£¬µÇ¼ºó£¬Ö»ÄܶÔtestÊý¾Ý¿â½øÐÐinsert²Ù×÷¡£
Æä±¾ÖÊÊÇÔÚLinux mysqlÖÐĬÈÏ°üº¬ÁËÒ»¸öLinux
mysqlµÄÊý¾Ý¿â£¬ÆäÖÐÓÐÒ»¸öuser±í£¬ÉÏÊöGRANTÃüÁîÆäʵ¾ÍÊÇÍùÕâ¸ö±íÖÐÌí¼ÓÁËÒ»ÐмǼ¡£Ò²¿ÉÒÔÖ±½ÓÐÞ¸ÄÕâ¸ö±í´ïµ½Í¬ÑùµÄЧ¹û£¬²»¹ý½ÏΪÂé·³¡£
×¢ÒâÌí¼ÓÃÜÂ룬¿ÉÒÔʹÓÃPASSWORD()º¯Êý¡£
7. Ô¶³ÌµÇ¼£¬ÒÔÔÚlinuxÏÂΪÀý£¨windowÏ¿ÉÓÃMysql GUI Tools):
$ mysql -u test -h
192.168.1.111 -p#È»ºóÊäÈëÃÜÂë¼´¿É
8. ½â¾öÊý¾Ý¿â±í²åÈëÖÐÎÄÏÔʾÂÒÂëÎÊÌ⣺
1)ÐÞ¸Ä/etc/my.cnfÎļþ£¬ÕÒµ½[mysqld]£¬ÔÚºóÃæ¼ÓÈëÒÔÏÂÐУº
default-character-set
= utf8
ͬʱн¨Ò»ÏÃûΪ[client]£¬ÔÚÖ®ºó²åÈëͬÉϵÄÓï¾ä¡£ÖØÆôLinux mysql·þÎñ¡£
2)
¶ÔÓÚ´´½¨Êý¾Ý¿âµÄsql½Å±¾£¬ÐèÒª¼ÓÈëÒÔÏÂÓï¾ä£º
drop da
Ïà¹ØÎĵµ£º
ÔÚÊý¾Ý¿âÖУ¬UNIONºÍUNION ALL¹Ø¼ü×Ö¶¼Êǽ«Á½¸ö½á¹û¼¯ºÏ²¢ÎªÒ»¸ö£¬µ«ÕâÁ½Õß´ÓʹÓúÍЧÂÊÉÏÀ´Ëµ¶¼ÓÐËù²»Í¬¡£
MySQLÖеÄUNION
UNIONÔÚ½øÐбíÁ´½Óºó»áɸѡµôÖظ´µÄ¼Ç¼£¬ËùÒÔÔÚ±íÁ´½Óºó»á¶ÔËù²úÉúµÄ½á¹û¼¯½øÐÐÅÅÐòÔËË㣬ɾ³ýÖظ´µÄ¼Ç¼ÔÙ·µ»Ø½á¹û¡£Êµ¼Ê´ó²¿·ÖÓ¦ÓÃÖÐÊDz»»á²úÉúÖظ´µÄ¼Ç¼£¬×î³£¼ûµÄÊǹý³Ì±íÓëÀúÊ·±íUNION¡£Èç ......
ÏÈÇ°ÔÚ²âÊÔmysql connect c++½Ó¿ÚµÄʱºòÔËÐÐÆä¹Ù·½ÌṩµÄÀý×Ó
21.5.5.6. MySQL Connector/C++ Complete Example 2
The following code shows a complete example of how to use MySQL Connector/C++:
/* Copyright 2008 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify ......
ÅäÖãº
binlog:ÓÃÓÚÔöÁ¿±¸·Ý
errorlog:¼à¿Ø´íÎóÐÅÏ¢
slow_query_log:¼à¿Ø²éѯ³¬Ê±µÄSQLÓï¾ä
data directory:Ìá¸ßÐÔÄÜ£¬±ãÓÚ¹ÜÀí
Ñ¡ÔñĬÈÏÊý¾Ý¿âÒýÇæ
INNODBÊý¾Ý¿âÒýÇæµÄÊý¾ÝĿ¼:Ìá¸ßÐÔÄÜ£¬±ãÓÚ¹ÜÀí
log_bin_trust_routine_creators=1 Èç¹û¸´ÖÆϵͳÀïÓÐʹÓõ½Óû§×Ô¶¨Ò庯Êý»ò´æ´¢¹ý³Ì ......
×¢Ò⣺mysqlÖеÄÓû§±äÁ¿µÄÉúÃüÖÜÆÚÊǻỰ¼¶µÄ£¬²»ÊÇÓï¾ä¼¶µÄ£¡
´æ´¢¹ý³Ì--------------------------------------------------
drop procedure if exists usp_simple;
delimiter //
create procedure usp_simple(in ip int, out op int, inout iop int)
begin
select count(*) into op from t1;
set op ......
wait(µÈ´ý×Ó½ø³ÌÖжϻò½áÊø)
±íÍ·Îļþ
#include<sys/types.h>
#include<sys/wait.h>
¶¨Ò庯Êý pid_t wait (int * status);
º¯Êý˵Ã÷
wait()»áÔÝʱֹͣĿǰ½ø³ÌµÄÖ´ÐÐ,Ö±µ½ÓÐÐźÅÀ´µ½»ò×Ó½ø³Ì½á
Êø¡£È ......