shell Öе÷Óà mysql ²Ù×÷
#!/bin/bash
#ɾ³ý100¸öÊý¾Ý¿âÖеÄ1000¸ö±íµÄ¹ýÆÚÊý¾Ý
DBHOST="127.0.0.1"
DBPWD="pwd"
DBUSER="root"
MYSQLBIN="/usr/local/mysql/bin/mysql"
for((dbindex = 0;dbindex < 100;dbindex++))
do
for((tabindex = 0;tabindex < 10;tabindex++))
do
if [ $dbindex -lt 10 ]; then
del="delete from gs_map_0${dbindex}.t_${tabindex}";
else
del="delete from gs_map_${dbindex}.t_${tabindex}";
fi
del=${del}" where Fcreate_time < UNIX_TIMESTAMP() - 86400"
bin=`${MYSQLBIN} -u${DBUSER} -p${DBPWD} -h${DBHOST} -e"${del}"`
$bin
#echo ${bin}
#echo $del >>/tmp/aaa.txt
sleep 5
done
done
#crontab configure
# 0 3 * * * clear.sh > /dev/null 2>&1
Ïà¹ØÎĵµ£º
MySQL ×Ö·û´®½ØÈ¡º¯Êý£ºleft(), right(), substring(), substring_index()¡£»¹ÓÐ mid(), substr()¡£ÆäÖУ¬mid(), substr() µÈ¼ÛÓÚ substring() º¯Êý£¬substring() µÄ¹¦Äܷdz£Ç¿´óºÍÁé»î¡£
1. ×Ö·û´®½ØÈ¡£ºleft(str, length)
mysql> select left('sqlstudy.com', 3);+-------------------------+| left('sqlstudy.com', 3) | ......
»¹ÔÒ»¸öÊý¾Ý¿â:mysql -h localhost -u root -p123456 www<c:\www.sql
±¸·ÝÒ»¸öÊý¾Ý¿â:mysqldump -h localhost -u root -p123456 www > d:\www2008-2-26.sql
//ÒÔÏÂÊÇÔÚ³ÌÐòÖнøÐвâÊÔ
//$command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupFile";
$command="mysqldum ......
1.DATE_FORMAT('2010-05-15 15:47:36','%H:%i:%s') -> ½á¹û£º15:47:36
½«ÈÕÆÚ¸ñʽ¸ù¾ÝÌõ¼þ²»Í¬×ª»»³ÉËùÐèÒªµÄÈÕÆÚ¡¢Ê±¼ä¸ñʽ
2.timediff('23:40:00', ' 18:30:00') -> ½á¹û£º05:10:00
......
Ò».°²×°
rpm·½Ê½
rpm -ivf MySQL*
tar·½Ê½
tar xzvf mysql-x.xx.tar.gz
cd mysqlp-x.xx Éú³Émakefile
./congigure
make ±àÒë
make install
mysql_install_db
¶þ.Æô¶¯¡¢¹Ø±Õ
ser ......
×÷/ÒëÕߣºÒ¶½ðÈÙ£¨Email: £©£¬À´Ô´£ºhttp://imysql.cn£¬×ªÔØÇë×¢Ã÷×÷/ÒëÕߺͳö´¦£¬²¢ÇÒ²»ÄÜÓÃÓÚÉÌÒµÓÃ;£¬Î¥Õ߱ؾ¿¡£
Ê×ÏÈ,ÕâÆ¬ÎÄÕ´¿´âÊÇÎҵĸöÈ˾Ñé̸֮,ÊÊÓÃÓÚÎÒ³£¼ûµÄ»·¾³¼°ÏîÄ¿ÖÐ.
¸öÈ˽¨Òé,Êý¾Ý¿â×Ö·û¼¯¾¡Á¿Ê¹ÓÃutf8(HTMLÒ³Ãæ¶ÔÓ¦µÄÊÇutf-8),ÒÔʹÄãµÄÊý¾ÝÄܺÜ˳ÀûµÄʵÏÖÇ¨ÒÆ,ÒòΪutf8×Ö·û¼¯ÊÇĿǰ×îÊʺÏÓÚÊ ......