mysqldump

MySql数据库备份的几种方式

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 05:50:45
mysqldump工具备份 备份整个数据库 $> mysqldump -u root -h host -p dbname > backdb.sql 备份数据库中的某个表 $> mysqldump -u root -h host -p dbname tbname1, tbname2 > backdb.sql 备份多个数据库 $> mysqldump -u root -h host -p --databases dbname1, dbname2 > backdb.sql 备份系统中所有数据库 $> mysqldump -u root -h host -p --all-databases > backdb.sql 直接复制整个数据库目录(对于InnoDB存储引擎不适用)备份 windowns: installpath/mysql/data linux: /var/lib/mysql 在复制前需要先执行如下命令: MYSQL> LOCK TABLES; # 在复制过程中允许客户继续查询表, MYSQL> FLUSH TABLES; # 将激活的索引页写入硬盘。 mysqlhotcopy工具备份 备份数据库或表最快的途径,只能运行在数据库目录所在的机器上,并且只能备份MyISAM类型的表。 要使用该备份方法必须可以访问备份的表文件。 $> mysqlhotcopy -u root -p

how to add date and time with backupfile name using mysqldump from command prompt and to define the path of backupfile

扶醉桌前 提交于 2019-12-06 05:19:20
问题 Im using this command for backup from mysqldump mysqldump -uroot -ptrackerdb) --alldatabases >test.sql Now i want to add date-time with my backup file like current date and time e.g test_25July2013_13:00 For this i add test_ date +%Y-%m-%d_%H-%M-%S .sql in file name but it gives error 'Couldn't find table': date +%Y-%m-%d_%H-%M-%S` What I'm doing wrong here? 回答1: I'm using that: LINUX mysqldump -u <user> -p <database> | bzip2 -c > <backup>$(date +%Y-%m-%d-%H.%M.%S).sql.bz2 WINDOWS (googled it

MySQL数据库备份和恢复

空扰寡人 提交于 2019-12-06 05:15:42
目录 MySQL数据库备份和恢复 备份恢复概述 为什么要备份 备份注意要点 还原要点 备份类型: 备份时需要考虑的因素 备份什么 备份工具 冷备份 cp tar mysqldump备份工具 模拟数据库崩溃,最大限度还原数据 mysqldump的分库备份 mysqldump的MyISAM存储引擎相关的备份选项: mysqldump的InnoDB存储引擎相关的备份选项: 生产环境实战备份策略 将误删除了的某个表进行还原 MySQL数据库备份和恢复 备份恢复概述 为什么要备份 灾难恢复:硬件故障、软件故障、自然灾害、黑客攻击、误操作测试等数据丢失场景 备份注意要点 能容忍最多丢失多少数据 恢复数据需要在多长时间内完成 需要恢复哪些数据 还原要点 做还原测试,用于测试备份的可用性 还原演练 备份类型: * 完全备份,部分备份 完全备份:整个数据集 部分备份:只备份数据子集,如部分库或表 * 完全备份、增量备份、差异备份 增量备份:仅备份最近一次完全备份或增量备份(如果存在增量)以来变化的数据,备份较快,还原复杂 差异备份:仅备份最近一次完全备份以来变化的数据,备份较慢,还原简单 * 注意:二进制日志文件不应该与数据文件放在同一磁盘 * 冷、温、热备份 冷备:读、写操作均不可进行 温备:读操作可执行;但写操作不可执行 热备:读、写操作均可执行 MyISAM:温备,不支持热备 InnoDB

mysql数据库的备份与还原

六月ゝ 毕业季﹏ 提交于 2019-12-06 04:52:10
备份结构 1.备份表结构 mysqldump -u root -p -d dbname table1 table2 ... > a.sql 2.备份数据库的所有表结构 mysqldumo -u root -p -d dbname > b.sql 3.备份多个数据库的所有表结构 mysqldump -u root -p -d --databases db1 db2... > c.sql 4.备份所有数据库的表结构 mysqldump -u root -p -d --all-databases > d.sql 备份结构和数据(相当于在备份结构的语法上去掉-d选项) 1.备份表结构和数据 mysqldump -u root -p dbname table1 table2 ... > a.sql 2.备份数据库的所有表结构和数据 mysqldump -u root -p dbname > b.sql 3.备份多个数据库的表结构和数据 mysqldump -u root -p --databases db1 db2 > c.sql 4.备份所有数据库的表结构和数据 mysqldump -u root -p --all-databases > d.sql 备份表数据 select ... into outfile select [列名] from table [where 语句] into

Get mysqldump to dump data suitable for psql input (escaped single quotes)

陌路散爱 提交于 2019-12-06 04:36:16
问题 I'm trying to port a database from MySQL to PostgreSQL. I've rebuilt the schema in Postgres, so all I need to do is get the data across, without recreating the tables. I could do this with code that iterates all the records and inserts them one at a time, but I tried that and it's waaayyyy to slow for our database size, so I'm trying to use mysqldump and a pipe into psql instead (once per table, which I may parallelize once I get it working). I've had to jump through various hoops to get this

MySQLDump--导出数据脚本异常

北城以北 提交于 2019-12-06 03:18:59
在一次使用mysqldump导出数据过程中,发现导出SQL无法正常执行,仔细观察后发下导出脚本为: (0,19264160,2,5085297,' Yimu(id:5085297)',''¥','[新教室V32] ',1559322451,NULL,31,NULL) 相同脚本再次执行导出SQL为: (0,19264160,2,5085297,' Yimu(id:5085297)','',0,0,'用户进入','[新教室V32] ',1559322451,NULL,31,NULL) 两次操作前后间隔不到3分钟,操作环境未发生任何变化,发生一次原因未知。 两次操作执行脚本为: (mysqldump \ --host="rm-xxxxxxxxxxx.mysql.rds.aliyuncs.com" \ --port=3306 \ --user="root" \ --password="root_password" \ --set-gtid-purged=OFF \ --default-character-set="utf8" \ --routines --triggers --hex-blob \ --databases 'db_xxxx' \ --tables 'tb_xxxx' \ --where='time<1559323221' \ >/tmp/tb_xxxx.sql) \ 1>

mysqldump partial database

半世苍凉 提交于 2019-12-06 02:26:23
问题 I recently decided to switch the company through which i get my hosting, so to move my old db into my new db, i have been trying to run this: mysqldump --host=ipaddress --user=username --password=password db_name table_name | mysql -u username -ppassword -h new_url new_db_name and this seemed to be working fine.. but because my database is so freaking massive, i would get time out errors in the middle of my tables. So i was wondering if there was any easy way to do a mysqldump on just part of

MYSQLDUMP备份

最后都变了- 提交于 2019-12-06 00:14:26
# MYSQLDUMP备份工具 ```sql /* 三种格式 */ mysqldump [OPTIONS] database [tables] mysqldump [OPTIONS] –B DB1 [DB2 DB3...] mysqldump [OPTIONS] –A [OPTIONS] - 官方:https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html - 选项 bash -A, --all-databases #备份所有数据库,含create database -B, --databases db_name… #指定备份的数据库,包括create database语句 -E, --events:#备份相关的所有event scheduler -R, --routines:#备份所有存储过程和自定义函数 --triggers:#备份表相关触发器,默认启用,用--skip-triggers,不备份触发器 --default-character-set=utf8 #指定字符集 --master-data[=#]: #此选项须启用二进制日志 1:所备份的数据之前加一条记录为CHANGE MASTER TO语句,非注释,不指定#,默认为1 2:记录为注释的CHANGE MASTER TO语句 此选项会自动关闭--lock

mysqldump schema only, schema update without drop

左心房为你撑大大i 提交于 2019-12-05 17:17:10
I'm looking at using the git pre-commit hook to export a MySQL db schema prior to commiting changes so that other developers can update their own databases with a SQL script from the git repo. By default a mysqldump (I'm using --no-data) will drop existing tables before rebuilding them which isn't what I'm after. I'm wondering if anyone knows of a way to do a mysqldump or similar to describe the db schemas with SQL to update tables if they exists instead of a drop and rebuild. I realize this might be a long shot but if anyone could point me in the right direction it would be great. How would

How to restore a mysql xml database file from mysql command line?

一曲冷凌霜 提交于 2019-12-05 16:18:51
I am running Windows XP, using the MySQL shell and PowerShell (MySQL 5.5), using XAMPP for Windows. I have an XML file which I've placed in E:\xampp\mysql\bin for convenience. I can run .\mysqldump.exe and .\mysql.exe but don't seem to be able to find the correct syntax for the type of XML file I'm using. The XML file is laid out like this: <mysqldump> <database name="export"> <table_structure name="export_rental_2006_property"> <field Field="id" Type="bigint(20)" Null="NO" Key="" Default="" Extra=""/> <field Field="name" Type="varchar(255)" Null="NO" Key="" Default="" Extra=""/> ...and so on,