mysqldump: Error: 'Access denied; you need (at least one of) the PROCESS privilege(s) for this operation' when trying to dump tablespaces
此情况是Process处理无权限,需要进行如下设置
用root用户登录进入mysql
mysql -uroot -p
grant process on *.* to 'backup'@'localhost';
flush privileges;
exit;
Backup名称需要更换成您自己的数据库名称.
在MYSQL8+中导出数据库可以使用以下方法跳过
mysql -uuser-ppwd --skip-definer database>base_without_definer.sql
也可以在常规导出后,用命令替换掉文件中的用户如
sed -i -- 's/`root`@`localhost`/`user2`@`localhost`/g' user2.sql
也可以直接删除记录中的所有触发器
mysql -uroot -ppwd -ANe "SELECT CONCAT('DROP TRIGGER ',trigger_name,';') FROM information_schema.triggers WHERE trigger_schema = 'test33';" | sed s'/\|//g' > DBNAME_drop_statement.sql
查询语句
SELECT Trigger_NameFROM `information_schema`.`TRIGGERS`WHERE TRIGGER_SCHEMA = 'test33';
查询数据库 test33中含有触发器的表,并生成一个可删除触发器的SQL语句到
DBNAME_drop_statement.sql
,可以得到以下文件
DROP TRIGGER trg_amasty_mostviewed_group_after_insert; DROP TRIGGER trg_amasty_mostviewed_group_after_update; DROP TRIGGER trg_amasty_mostviewed_group_after_delete; DROP TRIGGER trg_catalog_category_entity_after_insert; DROP TRIGGER trg_catalog_category_entity_after_update; DROP TRIGGER trg_catalog_category_entity_after_delete; DROP TRIGGER trg_catalog_category_entity_int_after_insert; DROP TRIGGER trg_catalog_category_entity_int_after_update; DROP TRIGGER trg_catalog_category_entity_int_after_delete; DROP TRIGGER trg_catalog_category_product_after_insert; DROP TRIGGER trg_catalog_category_product_after_update; DROP TRIGGER trg_catalog_category_product_after_delete; DROP TRIGGER trg_catalog_product_bundle_selection_after_insert; DROP TRIGGER trg_catalog_product_bundle_selection_after_update; DROP TRIGGER trg_catalog_product_bundle_selection_after_delete; DROP TRIGGER trg_catalog_product_entity_after_insert; DROP TRIGGER trg_catalog_product_entity_after_update; DROP TRIGGER trg_catalog_product_entity_after_delete; DROP TRIGGER trg_catalog_product_entity_datetime_after_insert; DROP TRIGGER trg_catalog_product_entity_datetime_after_update; DROP TRIGGER trg_catalog_product_entity_datetime_after_delete; DROP TRIGGER trg_catalog_product_entity_decimal_after_insert; DROP TRIGGER trg_catalog_product_entity_decimal_after_update; DROP TRIGGER trg_catalog_product_entity_decimal_after_delete; DROP TRIGGER trg_catalog_product_entity_gallery_after_insert; DROP TRIGGER trg_catalog_product_entity_gallery_after_update; DROP TRIGGER trg_catalog_product_entity_gallery_after_delete; DROP TRIGGER trg_catalog_product_entity_int_after_insert; DROP TRIGGER trg_catalog_product_entity_int_after_update; DROP TRIGGER trg_catalog_product_entity_int_after_delete; DROP TRIGGER trg_catalog_product_entity_text_after_insert; DROP TRIGGER trg_catalog_product_entity_text_after_update; DROP TRIGGER trg_catalog_product_entity_text_after_delete; DROP TRIGGER trg_catalog_product_entity_tier_price_after_insert; DROP TRIGGER trg_catalog_product_entity_tier_price_after_update; DROP TRIGGER trg_catalog_product_entity_tier_price_after_delete; DROP TRIGGER trg_catalog_product_entity_varchar_after_insert; DROP TRIGGER trg_catalog_product_entity_varchar_after_update; DROP TRIGGER trg_catalog_product_entity_varchar_after_delete; DROP TRIGGER trg_catalog_product_link_after_insert; DROP TRIGGER trg_catalog_product_link_after_update; DROP TRIGGER trg_catalog_product_link_after_delete; DROP TRIGGER trg_catalog_product_super_link_after_insert; DROP TRIGGER trg_catalog_product_super_link_after_update; DROP TRIGGER trg_catalog_product_super_link_after_delete; DROP TRIGGER trg_catalog_product_website_after_insert; DROP TRIGGER trg_catalog_product_website_after_update; DROP TRIGGER trg_catalog_product_website_after_delete; DROP TRIGGER trg_cataloginventory_stock_item_after_insert; DROP TRIGGER trg_cataloginventory_stock_item_after_update; DROP TRIGGER trg_cataloginventory_stock_item_after_delete; DROP TRIGGER trg_catalogrule_after_insert; DROP TRIGGER trg_catalogrule_after_update; DROP TRIGGER trg_catalogrule_after_delete; DROP TRIGGER trg_inventory_source_item_after_insert; DROP TRIGGER trg_inventory_source_item_after_update; DROP TRIGGER trg_inventory_source_item_after_delete;
在对应的数据库中执行它,清除整个数据库中的触发器