1.所需要软件mutt Linux下命令行邮件工具,可用来接收和发送邮件sendmail/postfix Linux下邮件服务器,所有邮件通过本机发送出去
1.所需要软件
mutt Linux下命令行邮件工具,可用来接收和发送邮件
sendmail/postfix Linux下邮件服务器,所有邮件通过本机发送出去
mysqldump 备份MySQL数据库的程序
2.mutt参数介绍
-a
-s
例子:
echo "你好,,祝你愉快!" | mutt -a /etc/passwd -s "Linux发送带附件的邮件" cc2@cc2.cc
说明:echo打印的内容为邮件正文,发送密码文件passwd到邮箱cc2@cc2.cc
3.脚本
测试备份的数据库名:
scriptdev2 realmd mmfpm mangos characters
查看数据库使用的字符集
show variables like "char%";
utf8
建立备份脚本
vi /root/send-mysql-data.sh
#!/bin/bash
#Power by hugwww 2009-4-11
#set time format
date=`date -d "%m"date -d today +"%Y-%m-%d-%H:%M"`
echo $date
#定义数组
db_array=(scriptdev2 realmd mmfpm characters mangos)
#取数组无元素个数
lenArray=${#db_array[@]}
#循环列出数组元素
i=0
while [ $i -lt $lenArray ]
do
#执行备份
mysqldump -uroot -ppassw0rd --default-character-set=utf8 --opt --extended-insert=false \
--triggers -R --hex-blob -x ${db_array[$i]} > /opt/db-backup/everyday/${db_array[$i]}-$date.sql;
# echo ${db_array[$i]}
let i++
done
#将所有SQL文件压缩到一个文件
tar cvzf /opt/db-backup/mysql-data-$date.tar.gz /opt/db-backup/everyday/*$date.sql
#发送备份文件到邮箱
echo "$date 数据库备份文件" | mutt -a /opt/db-backup/mysql-data-$date.tar.gz -s "mangos数据库备份" cc2@cc2.cc
echo "$date 备份成功并发送到指定邮箱" >> /opt/db-backup/backup.log
exit
完成

MySQL uses a GPL license. 1) The GPL license allows the free use, modification and distribution of MySQL, but the modified distribution must comply with GPL. 2) Commercial licenses can avoid public modifications and are suitable for commercial applications that require confidentiality.

The situations when choosing InnoDB instead of MyISAM include: 1) transaction support, 2) high concurrency environment, 3) high data consistency; conversely, the situation when choosing MyISAM includes: 1) mainly read operations, 2) no transaction support is required. InnoDB is suitable for applications that require high data consistency and transaction processing, such as e-commerce platforms, while MyISAM is suitable for read-intensive and transaction-free applications such as blog systems.

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

There are four main index types in MySQL: B-Tree index, hash index, full-text index and spatial index. 1.B-Tree index is suitable for range query, sorting and grouping, and is suitable for creation on the name column of the employees table. 2. Hash index is suitable for equivalent queries and is suitable for creation on the id column of the hash_table table of the MEMORY storage engine. 3. Full text index is used for text search, suitable for creation on the content column of the articles table. 4. Spatial index is used for geospatial query, suitable for creation on geom columns of locations table.

TocreateanindexinMySQL,usetheCREATEINDEXstatement.1)Forasinglecolumn,use"CREATEINDEXidx_lastnameONemployees(lastname);"2)Foracompositeindex,use"CREATEINDEXidx_nameONemployees(lastname,firstname);"3)Forauniqueindex,use"CREATEU

The main difference between MySQL and SQLite is the design concept and usage scenarios: 1. MySQL is suitable for large applications and enterprise-level solutions, supporting high performance and high concurrency; 2. SQLite is suitable for mobile applications and desktop software, lightweight and easy to embed.

Indexes in MySQL are an ordered structure of one or more columns in a database table, used to speed up data retrieval. 1) Indexes improve query speed by reducing the amount of scanned data. 2) B-Tree index uses a balanced tree structure, which is suitable for range query and sorting. 3) Use CREATEINDEX statements to create indexes, such as CREATEINDEXidx_customer_idONorders(customer_id). 4) Composite indexes can optimize multi-column queries, such as CREATEINDEXidx_customer_orderONorders(customer_id,order_date). 5) Use EXPLAIN to analyze query plans and avoid

Using transactions in MySQL ensures data consistency. 1) Start the transaction through STARTTRANSACTION, and then execute SQL operations and submit it with COMMIT or ROLLBACK. 2) Use SAVEPOINT to set a save point to allow partial rollback. 3) Performance optimization suggestions include shortening transaction time, avoiding large-scale queries and using isolation levels reasonably.


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

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Linux new version
SublimeText3 Linux latest version
