Mysql ±¸·ÝÓë»Ö¸´
mysql server4.0.18
Åú´¦ÀíÎļþÃûΪdbBackup.bat
ÄÚÈÝ£ºrem ÅжÏmysql·þÎñÊÇ·ñÆô¶¯£¬È»ºó½«²éѯ½á¹ûÊä³öµ½server.logÎļþÀï
netstat -na | (find "0.0.0.0:3306" & find "LISTENING")>server.log
rem ÊÖ¹¤½¨Á¢Ò»¸ö¿ÕµÄÎļþtemp.log£¬ÎªÁ˺Íserver.logÎļþÏà±È½Ï
rem ½«server.logÓëtemp.logÏà±È½Ï£¬Èç¹ûmysql·þÎñÒѾÆô¶¯£¬ÄÇôserver.logÎļþÖоͻáÓÐÐÅÏ¢¡£·ñÔòΪ¿Õ
fc server.log temp.log
rem Èç¹ûmysql·þÎñÒѾÆô¶¯£¬ÄÇô¾ÍÖ±½ÓÓÃmysqldump½øÐб¸·Ý£»Èç¹ûûÓÐÆô¶¯£¬Ò²¾ÍÊÇserver.logÎļþΪ¿Õ£¬ÄÇô¾Í»áÏÈ
rem Æô¶¯Êý¾Ý¿â£¬È»ºóÔÙ±¸·Ý
if not ERRORLEVEL 0 goto backup
@echo Trying to net start mysql
:backup
mysqldump -uroot mysql >back_%date:~4%.sql
×¢£ºÔÚ“%date:~4%”ÖÐ4±íʾ×îÖÕÏÔʾµÄÈÕÆÚ¸ñʽ
“4”±íʾÄêÔÂÈÕ¶¼ÏÔʾ
“8”±íʾֻÏÔʾÔÂÈÕ
“12”±íʾֻÏÔʾÈÕÆÚ
MysqlµÄ±¸·Ý
ÎÒÃǵÄÊý¾Ý¿âÐèÒª¾³£±¸·Ý£¬MysqlÊý¾Ý¿âµÄ³£Óñ¸·Ý·½·¨ÊÇʹÓÃʹÓÃʵÓóÌÐòmysqldump, ÆäÃüÁî¸ñʽÈçÏ£º
# mysqldump [options] database [tables]
Æä²ÎÊýµÄº¬ÒåΪ£º
options£º´ú±ímysqldumpµÄÑ¡Ïͨ¹ýmysqldump –help¿ÉÒԲ鵽¡£
database: ´ú±í½«Òª±¸·ÝµÄÊý¾Ý¿â
tables: ´ú±í½«Òª±¸·ÝµÄ±í£¬Èç¹û²»Ö¸¶¨ÈÎºÎ±í£¬Ôò±¸·ÝÕû¸öÊý¾Ý¿â¡£
ÀûÓÃϵͳcrontabÀ´¶¨Ê±Ö´Ðб¸·ÝÎļþ£¬°´ÈÕÆÚ¶Ô±¸·Ý½á¹û½øÐб£´æ£¬´ïµ½±¸·ÝµÄÄ¿µÄ¡£
1¡¢´´½¨±£´æ±¸·ÝÎļþµÄ·¾¶/mysqldata
#mkdir /mysqldata
2¡¢´´½¨/usr/sbin/bakmysqlÎļþ
#vi /usr/sbin/bakmysql
ÊäÈë
rq=` date +%Y%m%d `
tar zcvf /mysqldata/mysql$rq.tar.gz /var/lib/mysql
»òÕßд³É
rq=` date +%Y%m%d `
mysqldump --all-databases -u root -p980405 > /mysqldata/mysql$rq.tar.gz
/var/lib/mysqlÊÇÄãÊý¾Ý¿âÎļþµÄĿ¼£¬²¿·ÖÓû§ÊÇ/usr/local/mysql/data£¬Ã¿¸öÈË¿ÉÄܲ»Í¬
/mysqldata/±íʾ±£´æ±¸·ÝÎļþµÄĿ¼£¬Õâ¸öÿ¸öÈËÒ²¿ÉÒÔ¸ù¾Ý×Ô¼ºµÄÒªÇóÀ´×ö¡£
3¡¢ÐÞ¸ÄÎļþÊôÐÔ£¬Ê¹Æä¿ÉÖ´ÐÐ
# chmod +x /usr/sbin/bakmysql
4¡¢ÐÞ¸Ä/etc/crontab
#vi /etc/crontab
ÔÚÏÂÃæÌí¼Ó
01 3 * * * root /usr/sbin/bakmysql
±íʾÿÌì3µãÖÓÖ´Ðб¸·Ý
Ïà¹ØÎĵµ£º
¿ÉÒÔ½«Õâ¸ö½Å±¾·Å½øcrontab£¬ËûµÄÅäÖÆÎļþÔÚ /etc/crontabÖÐÿÌìÁ賿ִÐÐÒ»´Î£¬×Ô¶¯±¸·Ý Õâ¸ö½Å±¾Ã¿Ìì×î¶àÖ»Ö´ÐÐÒ»´Î£¬¶øÇÒÖ»±£Áô×î½üÎåÌìµÄ±¸·ÝÔÚ·þÎñÆ÷ÉÏ¡£
#!/bin/bash
#This is a ShellScript For Auto DB Backup
#Powered by aspbiz
#2004-09
#Setting
#ÉèÖÃÊý¾Ý¿âÃû£¬Êý¾Ý¿âµÇ¼Ãû£¬ÃÜÂ룬±¸·Ý·¾¶£¬ÈÕ־ ......
mysqlÉèÖÃÃÜÂëºÍÐÞ¸ÄÃÜÂ룺
/usr/local/mysql/bin/mysqladmin -uroot password 123456 µÚÒ»´ÎÉèÃÜÂë¡£
mysqladmin -uroot -p password mypasswd ÐÞ¸ÄÃÜÂë
ÊäÈëÕâ¸öÃüÁîºó£¬ÐèÒªÊäÈërootµÄÔÃÜÂ룬ȻºórootµÄÃÜÂ뽫¸ÄΪmypasswd¡£
¾ÍÊÇmysql5µ¼³öµÄÓÐdefault-charactµÄÉèÖã¬mysql4²»Ö§³Ö£¬ÐèÒª¼Óskip-opt²ÎÊý£¬È磺
my ......
Æô¶¯mysql: /etc/rc.d/init.d/mysql start
ÐÞ¸ÄÃÜÂë: ¸ñʽ£ºmysqladmin -uÓû§Ãû -p¾ÉÃÜÂë password ÐÂÃÜÂë
ʹÓÃÃÜÂëµÇ¼: mysql -u root -p
ÏÔʾÊý¾Ý¿â: show databases;
Ñ¡ÔñÊý¾Ý¿â: use Êý¾Ý¿âÃû;
ÏÔʾ±í: show tables;
ÏÔʾ±í½á¹¹: descibe ±íÃû;
Ô¶³ÌµÇ¼mysqlÐèÒª¿ªÆôÈ ......
MysqlµÄÓα꾿¾¹ÔõôÓÖӳÈպɻ¨±ðÑùºì
Mysql´Ó5.0¿ªÊ¼Ö§³Ö´æ´¢¹ý³ÌºÍtrigger£¬¸øÎÒÃÇϲ»¶ÓÃmysqlµÄÅóÓÑÃǸüϲ»¶mysqlµÄÀíÓÉÁË£¬Óï·¨
ÉϺÍPL/SQLÓвî±ð£¬²»¹ý¸ã¹ý±à³ÌµÄÈ˶¼ÖªµÀ£¬Óï·¨²»ÊÇÎÊÌ⣬¹Ø¼üÊÇ˼Ï룬´óÖÂÁ˽âÓï·¨ºó£¬¾Í´Ó
±äÁ¿¶¨Ò壬ѻ·£¬Åжϣ¬Óα꣬Òì³£´¦ÀíÕâ¸ö¼¸¸ö·½ÃæÏêϸѧϰÁË¡£¹ØÓÚÓαêµÄÓ÷¨M ......
¼¸¸öÔÂÇ°£¬ÊÜһλÀÏʦµÄίÍУ¬Òª°ïËû×öÒ»¸ö¹ØϵÊý¾Ý¿âģʽÐÅÏ¢ÌáÈ¡µÄСÏîÄ¿£¬Ö÷ÒªµÄ¹¦ÄÜʵÏÖ¾ÍÊǽ«¹ØϵÊý¾Ý¿âµÄ±í½á¹¹ºÍ×ֶεÄÐÅϢͨ¹ý±í¸ñµÄÐÎʽչʾ³öÀ´¡£ÎÒͨ¹ý´ÓÍøÉÏËѼ¯×ÊÁÏÒÔ¼°·Êé²éÕÒ£¬ÏÈʵÏÖÁËÒ»¸ömysqlµÄÊý¾ÝÌáÈ¡Æ÷¡£Ïȸø´ó¼Ò·ÖÏíһϡ£ÉÔºóµÄ¼¸ÌìÄÚ»á°ÑÁíÒ»¸ömysql¹ ......