一个MySQL的备份突然变小了很多,但实际的数据量却一直在增长。备份脚本也没有调整过。为什么呢?

重现了一下备份过程,发现备份中遇到了如下错误:

mysqldump: Got error: 1356: View 'wordpress.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them when using LOCK TABLES

原因: 视图引用的表不存在。

原理:mysqldump在备份时要对表加读锁,加锁失败的时候。备份就终止了。

解决方法:在备份时加上--force参数

模拟测试如下:

正常情况:

 

1.创建表t1并插入数据

CREATE TABLE `t1` (

`a` int(11) NOT NULL,

`b` int(11) DEFAULT NULL,

`c` int(11) DEFAULT NULL,

PRIMARY KEY (`a`),

UNIQUE KEY `b` (`b`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

insert into t1 values(1,3,5);

2.基于表t1创建视图

create view v_t1 as select * from t1;

3.模拟备份,可以正常备份出数据

mysqldump -ubkpuser -ps3cret   wordpress>wordpress.sql

模拟视图引用的表被删除:

1.删除表t1

mysql> drop table t1;

Query OK, 0 rows affected

mysql> select * from v_t1;

1356 - View 'wordpress.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them

2. 模拟备份,失败

$mysqldump -ubkpuser -ps3cret   wordpress  >wordpress1.sql

Warning: Using a password on the command line interface can be insecure.

mysqldump: Got error: 1356: View 'wordpress.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them when using LOCK TABLES

3. 增加force参数后,虽然有错误,但不影响备份

$mysqldump -ubkpuser -ps3cret  --force  wordpress  >wordpress1.sql

Warning: Using a password on the command line interface can be insecure.

mysqldump: Got error: 1356: View 'wordpress.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them when using LOCK TABLES

mysqldump: Couldn't execute 'SHOW FIELDS FROM `v_t1`': View 'wordpress.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them (1356)

[clouder@server2-86 ~]$ /home/clouder/vs/program/mysql/bin/mysqldump -uroot -p11 -S /home/clouder/vs/program/mysql/run/mysql.sock -h 172.16.2.86 --all-databases  --master-data=1 --flush-logs --force > /home/clouder/backup/alldatabase`date +%F-%H-%M-%S`.sql

mysqldump: Couldn't execute 'SHOW FIELDS FROM `ApiCommandAliasView`': View 'api.ApiCommandAliasView' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them (1356)

mysqldump: Couldn't execute 'SHOW FIELDS FROM `ApiReset`': View 'api.ApiReset' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them (1356)

mysqldump: Got error: 1356 mysqldump的重要参数--force的更多相关文章

  1. mysqldump 使用--tab=path参数时提示mysqldump: Got error: 1290: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement when executing 'SELECT INTO OUTFILE'

    报错: [root@zedu test]# mysqldump -h127.0.0.1 -uroot -p --single-transaction --add-drop-database --tab ...

  2. mysqldump: Got error: 1045

    问题:最近备份mysql然后在执行mysqldump的时候提示权限和密码有问题 报错: Warning: Using a password on the command line interface ...

  3. mysqldump: Got error: 1142: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'accounts' when using LOCK TABLES

    AutoMySQLBackup备份时,出现mysqldump: Got error: 1142: SELECT, LOCK TABLES command denied to user 'root'@' ...

  4. mysqldump: Got error: 1556: You can't use locks with log tables. when using LOCK TABLES

    mysqldump: Got error: 1556: You can't use locks with log tables. when using LOCK TABLES 我是把一些mysqldu ...

  5. mysqldump: Got error: 1135: Can't create a new thread (errno 11); if you are not out of available memory, you can consult the manual for a possible OS-dependent bug when trying to connect 解决办法

    在进行数据库备份的时候发现服务器报 mysqldump: Got error: 1135: Can't create a new thread (errno 11); if you are not o ...

  6. (转)mysqldump: Got error: 1556: You can't use locks with log tables.

    mysqldump: Got error: 1556: You can't use locks with log tables. 原文:http://blog.51cto.com/oldboy/112 ...

  7. mysqldump: Got error: 1449: The user specified as a definer ('user'@'%') does not exist when using LOCK TABLES

    报错:一个库用mysqldump -u -p --opt --force -e --max_allowed_packet= --net_buffer_length= --databases备份时报错如 ...

  8. 解决mysqldump: Got error: 1044: Access denied for user

    转自:http://blog.slogra.com/post-512.html 今天给新加的几个数据库备份,在执行mysqldump的时候,居然报mysqldump: Got error: 1044: ...

  9. mysql数据库导出时报错mysqldump: Got error: 145的解决方法

      在给mysql数据库备份时,报错:mysqldump: Got error: 145: Table './jxzhtopenfire/ofoffline' is marked as crashed ...

随机推荐

  1. 洛谷P4198 楼房重建(线段树)

    题意 题目链接 Sol 别问我为什么发两遍 就是为了骗访问量 这个题的线段树做法,,妙的很 首先一个显然的结论:位置\(i\)能被看到当且仅当\(\frac{H_k}{k} < \frac{H_ ...

  2. angular.js 教程 -- 实例讲解

    angular.js AngularJS [1] 诞生于2009年,由Misko Hevery 等人创建,后为Google所收购.是一款优秀的前端JS框架,已经被用于Google的多款产品当中.Ang ...

  3. CCNA学习笔记(1) IOS操作系统 路由器 交换机 启动 自检 以及部分命令

    注意:以下内容是以思科为学习环境 IOS操作系统启动: 路由和交换机和个人电脑启动没有区别,都会发送新号表示启动状态,也会进入系统自检.只得注意的是:1.一长两短的响声是显卡报警. 2.一声长鸣是内存 ...

  4. Python 基于python实现ADSL宽带帐号,密码的获取及宽带拨号

    基于python实现ADSL宽带帐号的获取及宽带拨号     基本思想: 1.研究上网方式(实验环境为电信网线接入式ADSL,拨号方式PPPOE) 2.研究宽带帐号和密码生成规律(实验环境,宽带帐号为 ...

  5. XQuery使用sum求和,提示char不能转换为money解决方法

    select axml.value('sum(/root/pro/price)','money') 以上代码提示‘char不能转换为money’的错误,发现值为'0.0E0'.改为: select a ...

  6. 用VisualAssist在Visual Studio上设置快捷键快速编程

    一  在Visual Studio上安装VisualAssist工具: 链接:https://pan.baidu.com/s/1uaeRFTvY4p7LNoDvQFEU5A 提取码:j1ws 安装后, ...

  7. Android--动态改变ImageView的亮度

    //改变图片的亮度方法 0--原样 >0---调亮 <0---调暗 private void changeLight(ImageView imageView, int brightness ...

  8. mongodb3.X权限配置

    环境: CentOS6.8  mongodb3.4.1 1.连接mongodb数据库(如果mongo命令没有做环境变量配置,需要定位到有mongo命令的目录) [root@VM_118_34_cent ...

  9. Mac下配置Golang环境

    1.go的官网:https://golang.org/ 下载地址:https://golang.org/dl/ ps:因为windows的影响我用的apk版本的安装比较简单,后面也会介绍环境变量的配置 ...

  10. HBase的写事务,MVCC及新的写线程模型

    MVCC是实现高性能数据库的关键技术,主要为了读不影响写.几乎所有数据库系统都用这技术,比如Spanner,看这里.Percolator,看这里.当然还有mysql.本文说HBase的MVCC和0.9 ...