解决mysqldump备份报错: Couldn't execute 'SHOW FIELDS FROM Unknown error 1356

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解决mysqldump备份报错: Couldn't execute 'SHOW FIELDS FROM Unknown error 1356相关的知识,希望对你有一定的参考价值。

服务器环境:

  1. [[email protected] mysql]# cat /etc/redhat-release
    CentOS Linux release 7.3.1611 (Core)
    [[email protected] mysql]# uname -a
    Linux localhost.localdomain 3.10.0-514.21.1.el7.x86_64 #1 SMP Thu May 25 17:04:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
    [[email protected] mysql]# CentOS Linux release 7.3.1611 (Core)


MySQL版本号:

mysql> select version();
+------------+
| version()  |
+------------+
| 5.7.13-log |
+------------+
1 row in set (0.00 sec)

报错具体情况:

  1. [[email protected] tmp]# mysqldump -uroot -p --default-character-set=utf8  --triggers -R --hex-blob --flush-logs  --events --single-transaction  --master-data=2  --all-databases|gzip >/tmp/134-20170831.sql.gz  
    Enter password:
    mysqldump: Couldn‘t execute ‘SHOW FIELDS FROM `v_product_info`‘: Unknown error 1356 (1356)

之前,由于数据库作主要用于测试,数据量不大,所以直接用的是mysqldump备份,没有出过问题。今天根据报错提示,是`v_product_info`这个视图出了问题;

下面排查问题所在:

  1. mysql> select * from information_schema.tables where TABLE_NAME LIKE ‘%v_product_info%‘ AND table_type=‘view‘\G;

    mysql> USE POSEIDON;

    mysql> SHOW CREATE  VIEW v_product_info\G;

  2. 下面为视图内容:
    CREATE ALGORITHM = UNDEFINED DEFINER = `dev_oheimdall_user`@`%` SQL SECURITY DEFINER VIEW `v_product_info` AS SELECT
        `a`.`id` AS `id`,
        `a`.`product_name` AS `product_name`,
        `a`.`feechannel_name` AS `feechannel_name`,
        `d`.`branch` AS `branch`,
        `a`.`product_city` AS `product_city`,
        `a`.`product_type` AS `product_type`,
        `a`.`mortgage_lend_terms` AS `mortgage_lend_terms`,
        `c`.`sparehouse_require` AS `sparehouse_require`,
        `a`.`lend_time_start` AS `lend_time_start`,
        `a`.`lend_time_end` AS `lend_time_end`,
        `a`.`month_rate_start` AS `month_rate_start`,
        `a`.`month_rate_end` AS `month_rate_end`,
        `a`.`repayment_mode` AS `repayment_mode`,
        `a`.`gmt_create` AS `gmt_create`,
        `a`.`status_name` AS `status_name`,
        `a`.`creater` AS `creater`,
        (
            CASE
            WHEN (
                `a`.`id` = `b`.`product_basic_id`
            ) THEN
                `b`.`credit`
            WHEN (
                `a`.`id` = `c`.`product_basic_id`
            ) THEN
                `c`.`credit_require`
            END
        ) AS `credit`
    FROM
        (
            (
                (
                    `product_basic` `a`
                    LEFT JOIN `product_credit_admit` `b` ON (
                        (
                            `a`.`id` = `b`.`product_basic_id`
                        )
                    )
                )
                LEFT JOIN `product_mortgage_admit` `c` ON (
                    (
                        `a`.`id` = `c`.`product_basic_id`
                    )
                )
            )
            LEFT JOIN `fund_channel` `d` ON (
                (
                    `a`.`feechannel_id` = `d`.`id`
                )
            )
        )

解决问题办法:

  1. 处理办法:
    mysql> DESC product_basic;
    ERROR 1146 (42S02): Unknown error 1146
    mysql> DESC product_mortgage_admit;
    ERROR 1146 (42S02): Unknown error 1146
    mysql> DROP VIEW v_product_info;
    Query OK, 0 rows affected (0.10 sec)

然后再进行备份,发现很快顺利完成。


本文出自 “莲池管俊涛的51cto博客” 博客,谢绝转载!

以上是关于解决mysqldump备份报错: Couldn't execute 'SHOW FIELDS FROM Unknown error 1356的主要内容,如果未能解决你的问题,请参考以下文章

mysqldump导出报错"mysqldump: Error 2013: Lost connection to MySQL server during query when dumping

Windows 下mysqldump备份1045错误解决办法

mysqldump: Couldn't execute 'SAVEPOINT sp':

mysqldump备份报错

mysql 备份报错mysqldump: [Warning] Using a password on the command line interface can be insecure.

mysqldump直接将MySQL数据库压缩备份遇到报错