zoukankan      html  css  js  c++  java
  • mysqldump: Got error: 1356 mysqldump的重要参数--force

    一个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)

  • 相关阅读:
    Javascript正则表达式详解转载
    转载Sqlserver2005 存储过程分页
    转载手把手教你用C#打包应用程序
    学习内容
    用C#实现将HTML文件转换为CHM文件(转)
    C# Windows服务添加安装程序
    sql 2008评估期已过有关如何升级,企业试用版到期,升级为企业版+sql2008破解
    iis不能启动是什么原因?错误提示:“提示服务器没有及时相应启动或控制请求”
    .NET 获取数据库中所有表名的方法
    如何获取Dynamics当前登录的用户的GUID,进而获取用户的信息
  • 原文地址:https://www.cnblogs.com/hixiaowei/p/8125407.html
Copyright © 2011-2022 走看看