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

AI Hentai Generator
Generate AI Hentai for free.

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 is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

There are three ways to view instance names in Oracle: use the "sqlplus" and "select instance_name from v$instance;" commands on the command line. Use the "show instance_name;" command in SQL*Plus. Check environment variables (ORACLE_SID on Linux) through the operating system's Task Manager, Oracle Enterprise Manager, or through the operating system.

Linux is suitable for servers, development environments, and embedded systems. 1. As a server operating system, Linux is stable and efficient, and is often used to deploy high-concurrency applications. 2. As a development environment, Linux provides efficient command line tools and package management systems to improve development efficiency. 3. In embedded systems, Linux is lightweight and customizable, suitable for environments with limited resources.

Field operation guide in MySQL: Add, modify, and delete fields. Add field: ALTER TABLE table_name ADD column_name data_type [NOT NULL] [DEFAULT default_value] [PRIMARY KEY] [AUTO_INCREMENT] Modify field: ALTER TABLE table_name MODIFY column_name data_type [NOT NULL] [DEFAULT default_value] [PRIMARY KEY]

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

To uninstall an Oracle database: stop the Oracle service, remove the Oracle instance, delete the Oracle home directory, clear the registry key (Windows only), and delete the environment variables (Windows only). Please back up the data before uninstalling.

Using Docker on Linux can improve development and deployment efficiency. 1. Install Docker: Use scripts to install Docker on Ubuntu. 2. Verify the installation: Run sudodockerrunhello-world. 3. Basic usage: Create an Nginx container dockerrun-namemy-nginx-p8080:80-dnginx. 4. Advanced usage: Create a custom image, build and run using Dockerfile. 5. Optimization and Best Practices: Follow best practices for writing Dockerfiles using multi-stage builds and DockerCompose.
