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

mysql ¶¨Ê±Êý¾Ý±¸·Ý

1.±àдshell½Å±¾
vi /data/www/project_name/bin/mysql_backup.sh
#!/bin/bash
#This is a ShellScript For Auto DB Backup
#Powered by liuzheng

#ϵͳ±äÁ¿¶¨Òå
DBName=test
DBUser=root
DBPasswd=123456
BackupPath=/tmp/mysql_backup/

NewFile="$BackupPath"db$(date +%y%m%d).tar.gz
DumpFile="$BackupPath"db$(date +%y%m%d).sql
OldFile="$BackupPath"db$(date +%y%m%d --date='1 days ago').tar.gz


#´´½¨±¸·ÝÎļþ
if [ ! -d $BackupPath ]; then
mkdir $BackupPath
fi

echo "---------------------------"
echo $(date +"%y-%m-%d %H:%M:%S")
echo "---------------------------"

#ɾ³ýÀúÊ·Îļþ
if [ -f $OldFile ]; then
¡¡¡¡rm -f $OldFile >> $LogFile
¡¡echo "[$OldFile]Delete Old File Success!"
else
echo "not exist old file!"
fi

#ÐÂÎļþ
if [ -f $NewFile ]; then
echo "[$NewFile] The Backup File is exists,Can't Backup! "
else
mysqldump -u $DBUser -p $DBPasswd $DBName > $DumpFile
tar czvf $NewFile $DumpFile
rm -rf $DumpFile
echo "[$NewFile]Backup Success!"
fi

2.¼Ó½øcrontab -e
#ÿÌìÔçÉÏ6µã¶¨Ê±±¸·ÝÒ»´Î
* 6 * * * /letv/app/php-5.2.6-fastcgi/bin/php-cgi /data/www/project_name/bin/mysql_backup.sh


Ïà¹ØÎĵµ£º

mysql³£ÓÃÖ¸ÁºÏ


Java´úÂë
mysql> select version(),current_date;   
²éѯmysqlµÄ°æ±¾ºÅ ºÍ  ÈÕÆÚ   
mysql> select version();   
²éѯmysqlµÄ°æ±¾ºÅ   
select now();   
²éѯµ±Ç°ÈÕÆÚºÍ׼ȷµÄʱ¼ä  
Java ......

mysql ×ÔÔöÁÐÏà¹ØÎÊÌâÕûÀí

MYSQL×ÔÔöÁÐ
1.¹Ø¼ü×Ö £ºauto_increment
2.×ÔÔöÓ÷¨
Àý:
CREATE TABLE animals ( id mediumint not null auto_increment,
name char(30) not null,
primary key (id));
3.¹ØÓÚ×ÔÔö
Q:Ôõô»ñµÃµ±Ç°µÄ×ÔÔöµÄ×î´óÖµ?
A:select @@identity
Q:Ôõô»ñµÃtableµÄµ±Ç°×ÔÔö×î´óÖµ?
A:select max(id) from table ......

mysqlÐÔÄÜÖ¸±ê

mysqladmin extended (¾ø¶ÔÖµ)
ÖصãÈ¥¼àÊÓµÄÖµÓУº
* Slave_running:Èç¹ûϵͳÓÐÒ»¸ö´Ó¸´ÖÆ·þÎñÆ÷£¬Õâ¸öÖµÖ¸Ã÷ÁË´Ó·þÎñÆ÷µÄ½¡¿µ¶È
* Threads_connected:µ±Ç°¿Í»§¶ËÒÑÁ¬½ÓµÄÊýÁ¿¡£Õâ¸öÖµ»áÉÙÓÚÔ¤ÉèµÄÖµ£¬µ«ÄãÒ²ÄܼàÊÓµ½Õâ¸öÖµ½Ï´ó£¬Õâ¿É±£Ö¤¿Í»§¶ËÊÇ´¦ÔÚ»îԾ״̬¡£
* Threads_running:Èç¹ûÊý¾Ý¿â³¬¸ººÉÁË£¬Ä㽫»áµÃµ½Ò»¸ö ......

MYSQLÒѾ­ÉúЧµÄÉèÖúÍ״̬²éѯÃüÁî

ÒÔÏÂÃüÁî¿ÉÒÔÔÚÈκÎÒѾ­Á¬½ÓÉÏMYSQL·þÎñÆ÷µÄ¿Í»§¶ËÉÏÖ´ÐС£
show full processlist ;
kill 57725;#ɱµôÉÏÃæ²éµ½µÄij¸öµ¼ÖÂ×èÈûµÄÁ¬½Ó
SELECT @@profiling;
SET profiling = 1;
SHOW PROFILES;
SHOW PROFILE for QUERY 1;
#ϵͳÉèÖÃ
show variables like '%key%';
show variables like '%key%';
show variables l ......

LinuxÏÂMySQL5.1µÄ°²×°

×î½üÏëÔÚ·þÎñÆ÷ÉÏÊÔÊÔMySQL5.1µÄ·ÖÇø£¬ÓÚÊǾÍÏë×Å×°¸öMySQL5.1£¬¾­¹ýÍ´¿àµÄÒ»¶Î¾­Àúºó£¬ÖÕÓÚÕÒ¸öÏÂÃæ×°¸öºÜºÃµÄ½Ì³Ì£¬ÌûÉÏÀ´±¸Íü¡£
1¡¢MySQLÃâ°²×°°æ/¶þ½øÖÆ°æÈí¼þ£¬²»ÓñàÒ룬ÏÂÔصØÖ·£º
     http://dev.mysql.com/downloads/
     Îļþ¸ñʽ£ºMYSQL-VERSION-OS.tar.gz
2¡¢´ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ