Whichever MySQL storage engine you use, built in recovery is far from perfect and it’s only a matter of time until you’ll experience some corruption / data loss.
Plan ahead and implement daily or weekly backups of all data.
There are four primary ways to backup a MySQL database:
1. IBBackup
The recommended way to bakcup a MySQL database, is by using a script called InnoDBBackup by the makers of InnoDB.
Pros: Works with both MyISAM and InnoDB. Fast. Doesn’t lock tables
Cons: Takes a few hours to setup
2. MySQLDump
Available from the early days of MySQL, MySQLDump is a command line utility provided by MySQL that works very well
To run, use:
mysqldump –user=user –single-transaction –password=pass –opt DBNAME > dumpfile.sql
The –opt flag is very important. This is shorthand to pass in many flags at once; –add-drop-table –add-locks –create-options –disable-keys –extended-insert –lock-tables –quick –set-charset. This ensures that your database is in a good state while the backup is performed, including restricting all write access while the backup is in operation. Any locks placed will be automatically removed when this utility finishes.
The –single-transaction flag is important for InnoDB tables. It starts a transaction and prevents any changes to the data while backup is running, to maintain data consistency.
Pros: Works with all table types.
Cons: Locks tables. Your database will be inaccessible while backup is running.
Note: If your database only consists of MyISAM tables, consider using mysqlhotcopy. It’s faster, but doesn’t work with InnoDB tables.
3. File copy
Copy the entire /data MySQL folder
Pros: Very easy to setup
Cons: You have to manually shutdown the database BEFORE starting the file copy, otherwise the backup will faill
4. MySQL Replication
Read our step-by-step guide about how to setup MySQL replication
Pros: The replication server can double as a live database, for performance (master-slave) and uptime (master-master)
Cons: Takes a few hours to setup
分享到:
相关推荐
在网上找了篇MySQL的技术文章,感觉不错,把它翻译过来共享下。 原文作者:Mike Peters 我整理了7条修复MySQL数据库的方法,当简单的重启对数据库不起作用,或者...较流行的存储引擎是MyISAM与InnoDB。 MyI
主要介绍了MySQL创建数据表时设定引擎MyISAM/InnoDB操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
MyISAM引擎与InnoDB引擎性能的对比
MyISAM和InnoDB的异同 MyISAM和InnoDB的异同
1、导出CentOS数据库的表结构 代码如下:mysqldump -d -uxxx -p centos > centos_table.sql其中-d参数表示不导出数据,只导出表结构2、替换centos_table.sql里的MyISAM为INNODB 代码如下:sed -i ‘s/MyISAM/INNODB/g...
自己总结的 关于mysql存储引擎myisam innodb 的比较 两者区别 对面试会很有帮助
MyISAM和InnoDB都使用B+树来实现索引: • MyISAM的索引与数据分开存储 • MyISAM的索引叶子存储指针,主键索引与普通索引无太大区别 • InnoDB的聚集索引和数据行统一存储 • InnoDB的聚集索引存储数据行本身,普通...
在使用MySQL的过程中对MyISAM和InnoDB这两个概念存在了些疑问,到底两者引擎有何分别一直是存在我心中的疑问。为了解开这个谜题,搜寻了网络,找到了如下信息: MyISAM是MySQL的默认数据库引擎(5.5版之前),由...
在MySQL 5.1之前的版本中,默认的搜索引擎是MyISAM,从MySQL 5.5之后的版本中,默认的搜索引擎变更为InnoDB。 2、MyISAM与InnoDB存储引擎的主要特点 MyISAM存储引擎的特点是:表级锁、不支持事务和全文索引,适合...
8.MySQL存储引擎--MyISAM与InnoDB区别1
InnoDB和MyISAM是许多人在使用MySQL时最常用的两个表类型,这两个表类型各有优劣,视具体应用而定。基本的差别为:MyISAM类型不支持事务处理等高级处理,而InnoDB类型支持。MyISAM类型的表强调的是性能,其执行数度...
数据库引擎 MyISAM 和 InnoDB 对比
InnoDB支持事务安全、Mysq唯一支持外键的存储引擎。使用要使用事务或者外键,InnoDB成为不二的选择。 但同时InnoDB提供了两种自动提交和手动提交两种选择(SET AUTOCOMMIT=0设置),根据文档所述,自动提交的性能...
MyISAM引擎与InnoDB引擎性能的对比,
主要介绍了Mysql 的存储引擎,myisam和innodb的区别,需要的朋友可以参考下
mysql数据库 选择合适的数据库引擎和myisam和innodb的主要区别