linux mysql备份数据库
#!/bin/sh # author shiwei.du # date 2013-10-30 NOW_TIME=`date "+%y%m%d%H%M%S"` # 现在时间戳 OVER_TIME=`date -d'3 day ago' "+%y%m%d%H%M%S"` #过期的时间戳 DBHOST=192.168.1.21 #服务器ip地址 DBNAME=test #数据库名称 DBUSER=root #操作者 DBPASSWD
#!/bin/sh
# author shiwei.du
# date 2013-10-30
NOW_TIME=`date "+%y%m%d%H%M%S"` # 现在时间戳
OVER_TIME=`date -d'3 day ago' "+%y%m%d%H%M%S"` #过期的时间戳
DBHOST=192.168.1.21 #服务器ip地址
DBNAME=test #数据库名称
DBUSER=root #操作者
DBPASSWD=****** #密码
DBCHARACTER=utf8 #数据库编码
BACKUPPATH="/home/mysqlbackup/" #备份路径
BACKUPLOG=$BACKUPPATH"mysqlbackup.log" #备份日志文件
# 判断存放备份文件的目录是否存在,不存在创建并修改文件的权限
if [ ! -d "$BACKUPPATH" ]; then
mkdir -p -m 700 "$BACKUPPATH"
fi
# 判断日志文件是否存在
if [ ! -f "$BACKUPLOG" ]; then
touch "$BACKUPLOG"
fi
# 执行mysqldump命令导出将要备份的数据库
`mysqldump -h$DBHOST -u$DBUSER -p$DBPASSWD --default-character-set=$DBCHARACTER --opt $DBNAME | gzip > $BACKUPPATH$DBNAME$NOW_TIME.sql.gz`
#记录日志文件
echo "[CREATE NEW BACKUP FLLE $BACKUPPATH$DBNAME$NOW_TIME.sql.gz SUCCESS!]"[`date "+%y-%m-%d %H-%M"`] >> $BACKUPLOG
#删除过期的备份文件
rm -f $BACKUPPATH$DBNAME$OVER_TIME.sql.gz | echo "[REMOVE FILE $BACKUPPATH$DBNAME$OVER_TIME.sql.gz SUCCESS!]" >> $BACKUPLOG
原文地址:linux mysql备份数据库, 感谢原作者分享。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











MySQL and phpMyAdmin can be effectively managed through the following steps: 1. Create and delete database: Just click in phpMyAdmin to complete. 2. Manage tables: You can create tables, modify structures, and add indexes. 3. Data operation: Supports inserting, updating, deleting data and executing SQL queries. 4. Import and export data: Supports SQL, CSV, XML and other formats. 5. Optimization and monitoring: Use the OPTIMIZETABLE command to optimize tables and use query analyzers and monitoring tools to solve performance problems.

DMA in C refers to DirectMemoryAccess, a direct memory access technology, allowing hardware devices to directly transmit data to memory without CPU intervention. 1) DMA operation is highly dependent on hardware devices and drivers, and the implementation method varies from system to system. 2) Direct access to memory may bring security risks, and the correctness and security of the code must be ensured. 3) DMA can improve performance, but improper use may lead to degradation of system performance. Through practice and learning, we can master the skills of using DMA and maximize its effectiveness in scenarios such as high-speed data transmission and real-time signal processing.

Handling high DPI display in C can be achieved through the following steps: 1) Understand DPI and scaling, use the operating system API to obtain DPI information and adjust the graphics output; 2) Handle cross-platform compatibility, use cross-platform graphics libraries such as SDL or Qt; 3) Perform performance optimization, improve performance through cache, hardware acceleration, and dynamic adjustment of the details level; 4) Solve common problems, such as blurred text and interface elements are too small, and solve by correctly applying DPI scaling.

In MySQL, add fields using ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column, delete fields using ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop. When adding fields, you need to specify a location to optimize query performance and data structure; before deleting fields, you need to confirm that the operation is irreversible; modifying table structure using online DDL, backup data, test environment, and low-load time periods is performance optimization and best practice.

macOS and Linux have their own advantages in compatibility and user experience. macOS has excellent compatibility within the Apple ecosystem, and the user experience is simple and intuitive; Linux has outstanding hardware compatibility and software flexibility. The user experience varies from distribution to distribution, emphasizing personalization and control.

To safely and thoroughly uninstall MySQL and clean all residual files, follow the following steps: 1. Stop MySQL service; 2. Uninstall MySQL packages; 3. Clean configuration files and data directories; 4. Verify that the uninstallation is thorough.

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.

Efficient methods for batch inserting data in MySQL include: 1. Using INSERTINTO...VALUES syntax, 2. Using LOADDATAINFILE command, 3. Using transaction processing, 4. Adjust batch size, 5. Disable indexing, 6. Using INSERTIGNORE or INSERT...ONDUPLICATEKEYUPDATE, these methods can significantly improve database operation efficiency.
