MySQL修改视图的definer
最近手头有个项目的数据库在迁移,迁移之后视图的definer需要更改。
先查看有哪些视图,及其对应的definer
select table_schema,table_name,definer from information_schema.views;
执行下面这条SQL生成修改definer的语句
select concat("alter DEFINER=`更改后的用户名`@`更改后的ip` SQL SECURITY DEFINER VIEW `",TABLE_SCHEMA,"`.",TABLE_NAME," as ",VIEW_DEFINITION,";") from information_schema.VIEWS where DEFINER = '修改前的用户名@修改前的ip';
复制生成的SQL执行修改definer,注意语句格式。