mysqldump

mysqldump参数详细说明

别说谁变了你拦得住时间么 提交于 2019-11-29 22:33:35
参数 参数说明 --all-databases , -A 导出全部数据库。 mysqldump -uroot -p --all-databases --all-tablespaces , -Y 导出全部表空间。 mysqldump -uroot -p --all-databases --all-tablespaces --no-tablespaces , -y 不导出任何表空间信息。 mysqldump -uroot -p --all-databases --no-tablespaces --add-drop-database 每个数据库创建之前添加drop数据库语句。 mysqldump -uroot -p --all-databases --add-drop-database --add-drop-table 每个数据表创建之前添加drop数据表语句。(默认为打开状态,使用--skip-add-drop-table取消选项) mysqldump -uroot -p --all-databases (默认添加drop语句) mysqldump -uroot -p --all-databases –skip-add-drop-table (取消drop语句) --add-locks 在每个表导出之前增加LOCK TABLES并且之后UNLOCK TABLE。(默认为打开状态,使用-

如何导出和导入mysql数据(数据迁移)

梦想的初衷 提交于 2019-11-29 22:33:19
这是其中一种方法,非常简单 1. 导出数据库数据 mysqldump -uroot -p dp_db > dumpout.sql 其中 root是账户名 dp_db是需要导出的数据库名称 dumpout.sql存储导出的数据 2. 将导出的数据dumpout.sql放到你的目标机器上(如果是远程目标机器的话,直接将dunmpout.sql copy到目标机器就行)。这里假设cp到主目录下~/ 3. 在目标机器的数据库里建立新数据库,这里建立名为dp_db_bak的数据库 mysql> create database dp_db_bak 4. 向dp_db_bak数据库导入数据 mysql -uroot -p dp_db_bak < ~/dumpout.sql 其中 root是账户名 db_db_bak是新数据库 ~/dumpout.sql是第一步导出的数据 P.S. 如果在导入导出数据的时候遇到文件太大异常退出的情况,可使用split/cat来进行文件的分割和合并 mysqldump -uroot -p dp_db | split -b 10m - tempfile cat all_tempfile > targetfile 其他方法: Mysql source命令在导入大数据时显得非常有用。虽然Mysql Administrator软件也不错

mysql mysqldump只导出表结构或只导出数据的实现方法

一世执手 提交于 2019-11-29 22:33:09
mysql mysqldump只导出表结构或只导出数据的实现方法,需要的朋友可以参考下。 mysql mysqldump 只导出表结构 不导出数据 复制代码 代码如下: mysqldump --opt -d 数据库名 -u root -p > xxx.sql 备份数据库 复制代码 代码如下: #mysqldump 数据库名 >数据库备份名 #mysqldump -A -u用户名 -p密码 数据库名>数据库备份名 #mysqldump -d -A --add-drop-table -uroot -p >xxx.sql 1.导出结构不导出数据 复制代码 代码如下: mysqldump --opt -d 数据库名 -u root -p > xxx.sql   2.导出数据不导出结构 复制代码 代码如下: mysqldump -t 数据库名 -uroot -p > xxx.sql  3.导出数据和表结构 复制代码 代码如下: mysqldump 数据库名 -uroot -p > xxx.sql  4.导出特定表的结构 复制代码 代码如下: mysqldump -uroot -p -B 数据库名 --table 表名 > xxx.sql   导入数据:   由于mysqldump导出的是完整的SQL语句,所以用mysql客户程序很容易就能把数据导入了: 复制代码 代码如下: #mysql

MySQL5.7.27报错“[Warning] Using a password on the command line interface can be insecure.”

跟風遠走 提交于 2019-11-29 20:49:13
MySQL5.7.27报错“[Warning] Using a password on the command line interface can be insecure.”在命令行使用密码不安全警告 原因 这个错误是在我执行备份脚本的时候出现的 # mysqldump -h主机名 -u用户名 -p密码 数据库名称 > /usr/local/dbbackup/数据库名称_$(date +%Y%m%d_%H%M%S).sql 原因是mysql的安全机制导致,因为在命令行直接将命令写上,被认为是不安全的行为 mysqldump: [Warning] Using a password on the command line interface can be insecure. 虽然会报错,但是并不影响是数据库的备份 解决方法 方法一:修改my.cnf配置文件 编辑/etc/my.cnf配置文件 [root@localhost local]# vi /etc/my.cnf 在配置文件中添加如下内容 [client] port = 3306 socket = /tmp/mysql.sock default-character-set = utf8mb4 host = 主机ip         user = 数据库用户名 password = '数据库密码'   使用命令导入导出

mysqldump & gzip commands to properly create a compressed file of a MySQL database using crontab

纵饮孤独 提交于 2019-11-29 19:48:07
I am having problems with getting a crontab to work. I want to automate a MySQL database backup. The setup: Debian GNU/Linux 7.3 (wheezy) MySQL Server version: 5.5.33-0+wheezy1(Debian) directories user, backup and backup2 have 755 permission The user names for MySQL db and Debian account are the same From the shell this command works mysqldump -u user -p[user_password] [database_name] | gzip > dumpfilename.sql.gz When I place this in a crontab using crontab -e * * /usr/bin/mysqldump -u user -pupasswd mydatabase | gzip> /home/user/backup/mydatabase-backup-`date +\%m\%d_\%Y`.sql.gz >/dev/null 2>

MySQL Error 2006 (HY000) at line 406: MySQL server has gone away

巧了我就是萌 提交于 2019-11-29 16:36:11
问题 I have a MYSQL dump from a database that I am trying to move to a new db server. When I try to import my sql dump, I receive the following error: MySQL Error 2006 (HY000) at line 406: MySQL server has gone away I googled the problem and most people fixed the problem by changing the value of wait_timeout. However, my current value is set to 28800 (8 hours) and the error appears in less than 8 seconds when I run the import. I also tried setting the value of max_allowed_packet to 1073741824 but

mysqldump全量备份+mysqlbinlog增量备份脚本

北慕城南 提交于 2019-11-29 15:51:09
mysql_mysqldump_backup.sh脚本代码: # Author: laizhiyuan # Date: 20190915 # Desc: Timed online logic backup MySQL By mysqldump cmd #!/bin/bash # 备份目的地IP BACK_DEST_IP=xx.xx.xx.xx # 备份目的地端口 BACK_DEST_PORT=22 # 备份目的地用户 BACK_DEST_USER=root # 目的地备份目录 BACK_DEST_DIR=/opt/backup/mysql/logic/full # 本地备份目录 BACK_DIR=/opt/backup/mysql/logic/full # 脚本工作目录 WORK_DIR=/tmp # mysql工作目录 MYSQL_BASEDIR=/usr/local/mysql # mysqldump命令参数 MYSQLDUMP_HOST=localhost MYSQLDUMP_PORT=3306 MYSQLDUMP_USER=root # 检查目录和环境 function check_mkdir_and_env(){ test ! -d $BACK_DIR && mkdir -p $BACK_DIR || echo "" > /dev/null ssh -p $BACK

How does phpMyAdmin Export work?

纵然是瞬间 提交于 2019-11-29 15:18:25
问题 Couldn't find a good answer to my question anywhere. If I were to want to create a php function that does the same thing as the Export tab in phpMyAdmin, how could I do it? I don't know if there is a mysql function that does this or if phpMyAdmin just builds the export file (in SQL that is) manually. Without shell access. Just using php. I tried the documentation for mysqldump, but that seemed to require using the shell (which I'm not quite sure what that even is -- maybe my question is How

MYSQL四种备份方法概述

寵の児 提交于 2019-11-29 15:13:50
Mysql 数据库 备份 主要有4种方法: 1、mysqldump 2、直接拷贝(cp、tar,gzip,cpio) 3、sqlhotcopy 4、同步复制 1、mysqldump备份: mysqldump生成能够移植到其它机器的文本文件,缺省地,文件内容包含创建正在倾倒的表的CREATE语句和包含表中行数据的INSERT语句。也就是说,mysqldump产生的输出可在以后用作mysql的输入来重建 数据库 。mysqldump比直接拷贝要慢些。 使用直接拷贝,如果正在备份的表正被读写就容易导致表损坏,而且不建议对isam表使用直接拷贝的方法来备份,因为ISAM表只能在相似的硬件结构的机器上拷贝。 使用方法:mysqldump [OPTIONS] database [tables] 输出文件的开头看起来象这样: # MySQL Dump 6.0 # # Host: localhost Database: samp_db #--------------------------------------- # Server version 3.23.2-alpha-log # # Table structure for table 'absence' # CREATE TABLE absence( student_id int(10) unsigned DEFAULT '0' NOT

How to obtain a correct dump using mysqldump and single-transaction when DDL is used at the same time?

China☆狼群 提交于 2019-11-29 14:50:39
问题 I'm new to MySQL and I'm figuring out the best way to perform an on-line hot logical backup using mysqldump . This page suggests this command line: mysqldump --single-transaction --flush-logs --master-data=2 --all-databases > backup_sunday_1_PM.sql but... if you read the documentation carefully you find that: While a --single-transaction dump is in process, to ensure a valid dump file (correct table contents and binary log position), no other connection should use the following statements: