我已经将一个包含视图的数据库从一台计算机迁移到另一台计算机,现在这些视图已经损坏了。我知道我需要在新机器上重新创建旧用户才能解决问题,但我的问题是:
我该如何找到创建视图的旧用户的用户名?我不再能够访问旧机器。
谢谢。
使用命令 SHOW CREATE VIEW 视图名称
您可以在https://dev.mysql.com/doc/refman/5.6/en/show-create-view.html中查看更多信息。
create view
,并在删除普通用户后由root用户重新登录,尽管会报告警告,但仍然显示了create view语法的详细信息。
mysql> show warnings \G ... Level: Note Code: 1449 Message: The user specified as a definer ('testuser'@'localhost') does not exist ... Level: Warning Code: 1356 Message: View 'stackoverflow.testview' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
- Kenneth L.select v.TABLE_SCHEMA, v.TABLE_NAME, v.`DEFINER`
from information_schema.VIEWS v
where v.TABLE_SCHEMA not in ('sys');