欢迎来到天天文库
浏览记录
ID:8853005
大小:36.50 KB
页数:7页
时间:2018-04-09
《编译安装mysql并写备份脚本加入定时任务》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、#yum-yinstallmakecmakegccgcc-c++gcc-g77flexbisonfilelibtoollibtool-libsautoconf libjpeglibjpeg-devellibpnglibpng-devellibpng10libpng10-develgdgd-develfreetypefreetype-devellibxml2libxml2-develzlibzlib-develglib2glib2-develbzip2bzip2-devellibeventlibevent-develncursesncurses-develcurlcurl-de
2、vele2fsprogse2fsprogs-develkrb5krb5-devellibidnlibidn-developensslopenssl-develvim-minimalnanofonts-chinesegettextgettext-develncurses-develgmp-develpspell-develunziplibcapdiffutils#tarxfmysql-5.6.2-m5.tar.gz #cdmysql-5.6.2-m5#cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DEXTRA_CHARSETS=all
3、-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci#make&&makeinstall#groupaddmysql#useradd-s/sbin/nologin-M-gmysqlmysql#cpsupport-files/my-medium.cnf/etc/my.cnf#sed'/skip-external-locking/idatadir=/usr/local/mysql/var'-i/etc/my.cnf#sed-i's:#innodb:innodb:g'/etc/my.cnf#sed-i's:/usr/l
4、ocal/mysql/data:/usr/local/mysql/var:g'/etc/my.cnf#/usr/local/mysql/scripts/mysql_install_db--defaults-file=/etc/my.cnf--basedir=/usr/local/mysql--datadir=/usr/local/mysql/var--user=mysql#chown-Rmysql:mysql/usr/local/mysql/#cpsupport-files/mysql.server/etc/init.d/mysqld#chmod+x/etc/init.d/m
5、ysqld#ln-s/usr/local/mysql/bin/mysql/usr/bin/mysql#ln-s/usr/local/mysql/bin/mysqldump/usr/bin/mysqldump#/etc/init.d/mysqldstart#chkconfigmysqldon#/usr/local/mysql/bin/mysqladmin-urootpassword'123456'#mysql-uroot-p>createdatabaselt;>showdatabases;>uselt;>CREATETABLEtest(numberINT(11),nameVAR
6、CHAR(255));>quit;备份mysqlmkdir-p/opt/shellvim/opt/shell/mysql_backup.sh脚本如下:#################################!/bin/bashbackdir='/data/mysql_bak'backtime=`date+%Y%m%d`DB_USER='root'DB_PASS='123456'DB_NAME='lt'mysql_dump='/usr/local/mysql/bin/mysqldump'if[!-d$backdir];then mkdir-p$backdirfi$m
7、ysql_dump-u${DB_USER}-p${DB_PASS}-B${DB_NAME}>$backdir/${DB_NAME}_${backtime}.sql####################################chmod+x /opt/shell/mysql_backup.sh然后添加定时任务#yuminstallcrontabs(如果执行crontab-e 出错的话,就先执行这个)crontab-e 添加0000***/opt/shell/mysql_backup.sh
此文档下载收益归作者所有