检查保护模式是否开启

show variables like 'sql_safe%';

如果是ON就设置为OFF

set sql_safe_updates=off;

(注1:不关闭保护模式无法修改权限,会报错:You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column.
(注2:修改后可通过执行set sql_safe_updates=on;恢复保护模式。)

设置数据库权限为“所有人”

use mysql;
update user set Host = '%' where User = '用户名';
select Host, User from user;
flush privileges;