mysqldump: Got error: 1449: The user specified as a definer ('xxx'@'%') does not exist when using LOCK TABLES


開發同學說在測試環境使用mysqldump導出數據的時候遇到以下錯誤:

# mysqldump -uroot -p  --all-databases --routines --events --triggers --no-data > /tmp/test.sql;
Enter password: 
mysqldump: Got error: 1449: The user specified as a definer ('xxx'@'%') does not exist when using LOCK TABLES

 

查看數據庫中的用戶,的確不存在:

select user,host from mysql.user;

  

因為庫中的數據是從別的地方導入的。導入后就刪除了上面的用戶'xxx'@'%'。但是庫中有一部分views是通過該用戶創建的。

 

現在需要找出這些視圖,並修改他們的定義者信息:

select concat("alter definer=`root`@`%` view ", table_name, " as ", view_definition, ";") 
from information_schema.views 
where table_schema='<你的數據庫名>';

  

執行上面查詢出語句,到你的數據庫中執行即可!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM