mysqldump

mysqldump exports only one table

依然范特西╮ 提交于 2019-12-02 14:16:26
I was using mysqldump to export the database, like this: mysqldump -u root -ppassword my_database > c:\temp\my_database.sql Somehow, it only exports one table. Is there something I'm doing wrong? try this. There are in general three ways to use mysqldump— in order to dump a set of one or more tables, shell> mysqldump [options] db_name [tbl_name ...] a set of one or more complete databases shell> mysqldump [options] --databases db_name ... or an entire MySQL server—as shown here: shell> mysqldump [options] --all-databases If you are dumping tables t1, t2, and t3 from mydb mysqldump -u... -p...

Import single database from --all-databases dump

若如初见. 提交于 2019-12-02 13:55:13
Is it possible to import a single database from an --all-databases mysqldump? I guess I can modify the file manually but wondering if there are any command line options to do this. I am moving servers and have a lot of databases, most of which I don't currently need or want at the moment but would like to have the option to restore a single one if need be. Quassnoi mysqldump output is just a set of SQL statements. You can provide the desired database in the command line and skip the commands against the other databases using: mysql -D mydatabase -o mydatabase < dump.sql This will only execute

Export Data from mysql Workbench 6.0

柔情痞子 提交于 2019-12-02 13:53:36
I'm trying to export my database, using MySQL Workbench 6.0 on Windows, to send to my db instance in Amazon RDS, but i'm getting this error: Operation failed with exitcode 7 11:34:40 Dumping clubbin (taxicompanies) Running: "C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqldump.exe" -defaults-extra- file="c:\users\selene\appdata\local\temp\tmp6o0hno.cnf" --max_allowed_packet=1G --delayed- insert=FALSE --host=localhost --user=root --port=3306 --default-character-set=utf8 "clubbin" "taxicompanies" mysqldump: [ERROR] unknown variable 'delayed-insert=FALSE' Does anybody have any idea that can help

Foreign key constraints while dumping data

馋奶兔 提交于 2019-12-02 13:18:40
mysqldump --compact --no-create-info -h192.168.150.180 -uroot -p live pnlbus_stops | sed s/pnlbus_stops/bus_stops/g | mysql test I am getting an error: ERROR 1062 (23000) at line 1: Duplicate entry 'AN' for key 1 This is because bus_stops table in the test DB has foreign key constraints. How do I truncate the bus_stops table from test database in a SINGLE STATEMENT before inserting from "live" DB? put set FOREIGN_KEY_CHECKS = 0; at the top of your dump file and put SET FOREIGN_KEY_CHECKS = 1; at the bottom of your dump file 来源: https://stackoverflow.com/questions/1382583/foreign-key

mysql数据库的备份与数据恢复

梦想的初衷 提交于 2019-12-02 11:48:24
一、定时备份数据库 前段时间工作中搭建了HttpRunnerManager的接口自动化测试平台,由于平台中没有提供用例下载的功能及权限管理功能,自己也不会写前端,于是就想了办法,那就是备份数据库,如果有人误删了数据,那么可以通过备份的数据库来进行数据恢复。接下来记录一下数据库的备份与恢复操作记录。 1. 创建shell脚本 vim mysql_autobackup.sh 创建脚本内容如下: #!/bin/sh db_user="root" db_passwd="123456" db_name="userdb" name="$(date +"%Y%m%d%H%M%S")" /usr/bin/mysqldump -u$db_user -p$db_passwd $db_name >>/home/ceshi/backup/$name.sql 说明: /usr/bin/mysqldump :mysql数据库安装目录下的mysqldump备份工具路径 dbname :需要备份的数据库名字 /home/ceshi/backup/$name.sql :备份文件输出位置,可以根据情况自行设定 2. 给shell脚本添加执行权限 chmod +x mysql_autobackup.sh 然后我自己测试了一下,运行 mysql_autobackup.sh脚本的时候,提示:Warning: Using a

linux下mysql导入导出sql文件

风格不统一 提交于 2019-12-02 11:10:30
使用mysqldump导出数据库: # mysqldump -u root -p gzy > gzy.sql # mysqldump -u 数据库连接用户名 -p 目标数据库 > 存储的文件名 使用sql文件导入数据库: # mysql -u 用户名 -p 数据库名 < 数据库名.sql # mysql -u root -p gzy < gzy.sql 来源: https://www.cnblogs.com/flypig666/p/11742546.html

Error importing MySQL data across platforms (MAMP to WIMP)

狂风中的少年 提交于 2019-12-02 09:51:38
I've dumped a MySQL database I have on my local MAMP server into a .sql file. Usually, it's easy enough for me to import that file to my production Linux servers without a hitch. However, my current client runs MySQL on WIMP, and when import the MAMP-generated .sql dump into my WIMP mysql environment (Using pphpMyAdmin) I get a "File could not be read" error? Any ideas of what I'm bumping up against, or what to check? Thanks- EDIT: My initial explanation was unclear- I'm trying to export out of MAMP, and import into WIMP The most likely cause for this problem is the different end of line

备份

不羁岁月 提交于 2019-12-02 09:38:11
1、备份命令 格式:mysqldump -h主机名 -P端口 -u用户名 -p密码 --database 数据库名 > 文件名.sql 例如: mysqldump -h 192.168.1.100 -p 3306 -uroot -ppassword --database cmdb > /data/backup/cmdb.sql 2、备份压缩 导出的数据有可能比较大,不好备份到远程,这时候就需要进行压缩 格式:mysqldump -h主机名 -P端口 -u用户名 -p密码 --database 数据库名 | gzip > 文件名.sql.gz 例如: mysqldump -h192.168.1.100 -p 3306 -uroot -ppassword --database cmdb | gzip > /data/backup/cmdb.sql.gz 3、备份同个库多个表 格式:mysqldump -h主机名 -P端口 -u用户名 -p密码 --database 数据库名 表1 表2 .... > 文件名.sql 例如 mysqldump -h192.168.1.100 -p3306 -uroot -ppassword cmdb t1 t2 > /data/backup/cmdb_t1_t2.sql 4、同时备份多个库 格式:mysqldump -h主机名 -P端口 -u用户名

MySQL备份工具——Xtrabackup之简介

╄→尐↘猪︶ㄣ 提交于 2019-12-02 07:54:21
MySQL备份工具——Xtrabackup之简介 一、简介 1 、 xtrabackup 是 percona 公司开发的一款基于 MySQL 的开源备份工具,且优于 ibbackup 。 2 、 xtradb 存储引擎也是 percona 公司为 MySQL 开发的,是 InnoDB 的增强版。 3 、 xtradb 存储引擎的使用: ①、编译安装 MySQL ; ②、删除原有的 InnoDB 源文件: innobase 目录; ③、下载 xtradb 的源代码到,并重命名为 innobase 目录; ④、正常的编译安装。 4 、也可以直接使用 mariaDB ,同 mysql ,默认使用 xtradb 作为默认的存储引擎,使用无差别。 5 、备份类型: ①、 InnoDB :完全备份、增量备份 ②、 MyISAM :完全备份 6 、据官方介绍,这也是世界上唯一一款开源的能够对 InnoDB 和 xtradb 存储引擎进行热备的工具。 7 、特点: ①、备份速度快、可靠; ②、备份过程不会打断正在执行的事务; ③、能够给予压缩等功能,节约磁盘空间和流量(传输); ④、自动实现备份检查; ⑤、还原速度快。 8 、 Xtrabackup 有两个主要的工具: xtrabackup 、 innobackupex ①、 xtrabackup :只能备份 InnoDB 和 XtraDB

13-2 13 mysql 用户管理 sql语句 mysql数据库备份恢复

落爺英雄遲暮 提交于 2019-12-02 07:34:26
13.4 mysql用户管理 13.5 常用sql语句 13.6 mysql数据库备份恢复 13.4 MySQL用户管理 MySQL创建用户以及授权 mysql -uroot -p grant all on *.* to 'user1'@'127.0.0.1' identified by '1234a'; //第一个*为库,第二个*为表 quit mysql -uuser1 -p1234a -h127.0.0.1 [ctrl-d] mysql -uroot p grant all on *.* to 'user1' identified by '1234a'; exit mysql -uuser1 -p1234a -h试试看 还可以: grant SELECT,UPDATE,INSERT on db1.* to 'user2'@'192.168.83.1' identified by 'passwd'; grant all on db1.* to 'user3'@'%' identified by 'passwd'; show grants; 查看当前用户权限 show grants for user1@127.0.0.1; show grants for user2@192.168.83.1; 两行可以用于迁移用户IP,两行改IP执行下,原密码会保留 13.5 常用sql语句