我的原文所在 http://yanmin.in/archive.html
官方教程 refer to:https://help.aliyun.com/knowledge_detail/5975231.html
出现ERROR 1227 (42000) at line 18: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
问题,则剑走偏锋:
- 在本地命令行输入:
$ mysqldump -h local_ip -u user_name -p --opt --default-character-set=utf8 --hex-blob db_name --skip-triggers > /tmp/db_name.sql
local_ip 以您真实的线下MySQL服务器IP地址代替(例如:rdxxxxsxxxxxxxxxxo.mysql.rds.aliyuncs.com)
user_name 以您真实的数据库用户代替(例如:ubutu)
db_name 以您真实的数据库名代替
db_name.sql是文件名,由您自己随意填写。
$ mysql -h local_ip -u user_name -p db_name< db_name.sql
此时有报错ERROR 1227 (42000) at line 18: Access denied; you need (at least one of) the SUPER privilege(s) for this operation,本能地命令行执行:
$ sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' db_name.sql >db_name_revised.sql
$ sed '/GTID_PURGED/N;s/,\n/,/' db_name_revised.sql | grep -iv 'set @@'> db_name_db_revised.sql
$ mysql -u user_name -p -h local_ip db_name_test < db_name_db_revised.sql
重新查看数据库,应该就可以使用了