mysqldump

Can I restore a single table from a full mysql mysqldump file?

喜夏-厌秋 提交于 2019-11-26 09:28:30
I have a mysqldump backup of my mysql database consisting of all of our tables which is about 440 megs. I want to restore the contents of just one of the tables form the mysqldump. Is this possible? Theoretically, I could just cut out the section that rebuilds the table I want but I don't even know how to effectively edit a text document that size. uloBasEI You can try to use sed in order to extract only the table you want. Let say the name of your table is mytable and the file mysql.dump is the file containing your huge dump: $ sed -n -e '/CREATE TABLE.*`mytable`/,/CREATE TABLE/p' mysql.dump

Restore the mysql database from .frm files

跟風遠走 提交于 2019-11-26 09:19:58
问题 I have dumped all my tables everyweek to got the backup. But later I understand that it is only storing the .frm file of the table. It is not showing .MYD and .MYI files of a table. So I have only my .frm file of the database with me and also mydatabase is innodb. So can I get my database with data in the database? 回答1: Yes this is possible. It is not enough you just copy the .frm files to the to the databse folder but you also need to copy the ib_logfiles and ibdata file into your data

Mysql数据库备份

佐手、 提交于 2019-11-26 09:15:27
备份数据库 一.使用cmd命令行执行数据备份: 备份命令代码格式: mysqldump -h数据库服务器IP -P数据库使用端口号 -u账户 -p密码 数据库名>保存路径 mysqldump -h127.0.0.1 -p3306 -uroot -proot zbsqx>D:\MysqlBackup\20190807.sql 在命令行中输入以上代码: 例子: 以上例子是使用root用户备份数据库zbsqx,数据库端口为3306,数据库位于本机(IP:127.0.0.1) 执行后D盘的MysqlBackup路径下就有了一个名字为20190807.sql的备份文件 如果提示:不是内部或外部命令时, 主要是mysqldump命令不是在mysql的bin目录下执行, 这里由于我配置了msyql的环境变量,可以在命令窗口的默认目录下执行mysqldump命令。 在环境变量的path栏里面添加mysql下面的bin文件夹路径即可, 例如我是:C:\Program Files\MYSQL\MySQL Server 5.7\bin\ 二.使用Java代码实现数据库备份: 在做项目时,数据库会不断的修改!所以要对数据进行不断备份!如果被修改的数据库出现问题还可以使用以前备份的数据进行临时使用!但使用mysql的select命令来导出数据表,不实用,因为一次只能导出单一表格,而且有数据库权限问题。

Cloning a MySQL database on the same MySql instance

天大地大妈咪最大 提交于 2019-11-26 08:44:42
问题 I would like to write a script which copies my current database sitedb1 to sitedb2 on the same mysql database instance. I know I can dump the sitedb1 to a sql script: mysqldump -u root -p sitedb1 >~/db_name.sql and then import it to sitedb2 . Is there an easier way, without dumping the first database to a sql file? 回答1: As the manual says in Copying Databases you can pipe the dump directly into the mysql client: mysqldump db_name | mysql new_db_name If you're using MyISAM you could copy the

How can I access the MySQL command line with XAMPP for Windows?

拟墨画扇 提交于 2019-11-26 07:54:00
问题 How can I access the MySQL command line with XAMPP for Windows? 回答1: Your MySQL binaries should be somewhere under your XAMPP folder. Look for a /bin folder, and you'll find the mysql.exe client around. Let's assume it is in c:\xampp\mysql\bin, then you should fireup a command prompt in this folder. That means, fire up "cmd", and type: cd c:\xampp\mysql\bin mysql.exe -u root --password If you want to use mysqldump.exe, you should also find it there. Log into your mysql server, and start

Import MySQL database into a MS SQL Server

ε祈祈猫儿з 提交于 2019-11-26 06:18:39
问题 I have a .sql file from a MySQL dump containing tables, definitions and data to be inserted in these tables. How can I convert this database represented in the dump file to a MS SQL Server database? 回答1: Use SQL Server Migration Assistant (SSMA) In addition to MySQL it supports Oracle, Sybase and MS Access. It appears to be quite smart and capable of handling even nontrivial transfers. It also got some command line interface (in addition to GUI) so theoretically it can be integrated into some

How can I get rid of these comments in a MySQL dump?

血红的双手。 提交于 2019-11-26 05:28:47
问题 I\'m trying to create a simple structure only dump of my database. Using mysqldump gives me a result like: /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO\' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; DROP TABLE IF EXISTS `foo`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET

MySQL的备份还原(mysqldump)

∥☆過路亽.° 提交于 2019-11-26 05:26:35
MySQL的备份还原(mysqldump) MySQL的还原前提是要建立在,有完全备份和二进制日志开启的前提下,并且二进制日志文件和完全备份存放在与数据库文件不同的磁盘上,否则当磁盘发生损坏数据将无法进行恢复。 开启二进制日志 开启二进制日志需要将MySQL中的sql_log_bin和log_bin这两个选项 1.开启sql_log_bin 系统中默认开启sql_log_bin选项所以此处无需修改 MariaDB [(none)]> SHOW VARIABLES LIKE 'sql_log_bin'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | sql_log_bin | ON | +---------------+-------+ 1 row in set (0.01 sec) 2.开启log_bin 此选项需要对MySQL的配置文件进行修改,在修改之前需要先创建一个二进制日志存放的位置。 注意:不要和数据库存放在统一磁盘内,不要和数据库存放在统一磁盘内,不要和数据库存放在统一磁盘内 重要的事情说三遍。 [root@localhost ~]# mkdir /data/bin [root@localhost ~]# chown -R mysql.mysql /data

MySQL全量、增量备份与恢复(重点!!!)

六月ゝ 毕业季﹏ 提交于 2019-11-26 02:51:31
数据备份的重要性 1、在生产环境中,数据的安全性是至关重要的,任何数据的丢失都可能产生严重的后果 2、造成数据丢失的原因 程序错误 人为错误 计算机失败 磁盘失败 灾难(如地震等)和偷窃 数据库备份的分类 一、从物理与逻辑的角度,备份可分为: 1、物理备份:对数据库操作系统的物理文件(如数据文件、日志文件等)的备份 物理备份又可以分为脱机备份(冷备份)和联机备份(热备份): -冷备份:是在关闭数据库的时候进行的 -热备份:数据库处于运行状态,这种备份方法依赖于数据库的日志文件 2、逻辑备份:对数据库逻辑组件(如表等数据库对象)的备份 二、从数据库的备份策略角度, 备份可分为: 1、完全备份:每次对数据进行完整的备份 2、差异备份:备份那些自从上次完全备份之后被修改过的文件 3、增量备份:只有那些在.上次完全备份或者增量备份后被修改的文件才会被备份 注意点:差异备份与增量备份相辅相成 MySQL完全备份(全量备份) 1、完全备份是对整个数据库的备份、数据库结构和文件结构的备份 2、完全备份保存的是备份完成时刻的数据库 3、完全备份是增量备份的基础 完全备份的优点 备份与恢复操作简单方便 完全备份的缺点 1.数据存在大量的重复 2.占用大量的备份空间 3.备份与恢复时间长 mysqldump备份库 一、MySQL数据库的备份可以采用用多种方式 1.直接打包数据库文件夹,如/usr

Mysql数据库的备份与恢复

我是研究僧i 提交于 2019-11-26 02:49:47
数据备份的重要性 在生产环境中,数据的安全性是至关重要的,任何数据的丢失都可能产生严重的后果 造成数据丢失的原因 程序错误 人为错误(常事) 计算机失败 磁盘失败 灾难 数据库备份的分类 物理备份 对数据库操作系统的物理文件(如数据文件,日志文件等)的本份 物理备份又可以分为脱机备份(冷备份)和联机备份(热备份) 冷备份:实在关闭数据库的时候进行的 热备份:数据库处于运行状态,这种备份方法依赖于数据库的日志文件 逻辑备份 :对数据库逻辑组件(如表等数据库对象)的备份 从数据库的备份策略角度,备份可分为 完全备份:每次对数据进行完整的备份 差异备份:备份那些自从上次完全备份之后被修改的文件 增量备份 :只有那些在上次完全备份或者增量备份后被修改的文件才会被备份 增量备份 ,第一点在完全备份基础之上,a,b,c增量修改之后会就b+,c+增量备份。在这两个文件增量备份之后,再备份修改,b+b+ 完全备份 完全备份是对整个数据库的备份,数据库结构和文件结构的备份 完全备份保存的是备份完成时刻的数据库 完全备份是增量备份的基础 完全备份的优缺点 优点:备份与恢复操作简单方便 缺点:数据存在大量的重复,占用大量的备份空间,备份与恢复时间长 mysqldump备份库 Mysql数据库的备份可以采用多种方式 直接打包数据库文件夹,如/usr/local/mysal/data