进行mysqldump导出的时候报:mysqldump: Couldn't execute 'show table status like 'v\_edit\_new\_product\_info'': SELECT command denied to user ''@'172.21.18.13' for column 'product_code' in table 'pc_productinfo' (1143)
过程:
root@mysql-MASTER-10-10-19-11:/opt/mysql# /opt/mysql/bin/mysqldump -uroot -p --default-character-set=utf8 --skip-lock-tables --hex-blob=true -E -R --comments --databases productcenter systemcenter usercenter webcore zapdata> /opt/mysql/bak_10.10.9.1_20180918.sql
Enter password:
mysqldump: Couldn't execute 'show table status like 'v\_edit\_new\_product\_info'': SELECT command denied to user ''@'172.21.18.13' for column 'product_code' in table 'pc_productinfo' (1143)
将pc_productinfo忽略,加上参数--ignore-table=productcenter.pc_productinfo:
root@mysql-MASTER-10-10-19-11:/opt/mysql# /opt/mysql/bin/mysqldump -uroot -p --default-character-set=utf8 --skip-lock-tables --hex-blob=true -E -R --comments --databases productcenter systemcenter usercenter webcore zapdata --ignore-table=productcenter.pc_productinfo ?> /opt/mysql/bak_10.10.9.1_20180918.sql
Enter password:?
mysqldump: Couldn't execute 'show table status like 'v\_edit\_new\_product\_info'': SELECT command denied to user ''@'172.21.18.13' for column 'product_code' in table 'pc_productinfo' (1143)
仍然报错。
暂时先不导出productcenter库:
root@mysql-MASTER-10-10-19-11:/opt/mysql# /opt/mysql/bin/mysqldump -uroot -p --default-character-set=utf8 --skip-lock-tables --hex-blob=true -E -R --comments --databases systemcenter usercenter webcore zapdata > /opt/mysql/bak_10.10.9.1_20180918.sql
Enter password:
mysqldump: Couldn't execute 'show table status like 'v\_edit\_new\_product\_info'': SELECT command denied to user ''@'172.21.18.13' for column 'product_code' in table 'pc_productinfo' (1143)
还是不行!仔细观察报错:show table status like 'v_edit_new_product_info',进库里查了下这个是个视图;
而用户为user ''@'172.21.18.13',说明这个视图的definer已经被删了,数据库里现在不存在。
两种解决方法:
1、将被删的用户重新建上:
select definer from views where table_name='pc_productinfo';
grant select on productcenter.* to 'xxx'@'172.21.18.13';
2、更新视图的definer:
update views set definer='xxxx' where table_name='pc_productinfo';
使用了第二种方法,解决。
注意表可能也存在这种情况,具体情况具体解决。