我有几千个 MySQL 用户都设置为允许从特定主机访问。问题是现在我将拥有两台机器(将来会更多),它们需要使用同一个帐户来访问它们的每个数据库。
我想要一种快速简便(尽可能自动化)的方式来运行和修改每个用户帐户的主机部分以适应内部网络通配符。例如:
'bugsy'@'internalfoo' has access to the 'bugsy' DB.
我现在想允许从内部网络的任何地方进行错误访问
'bugsy'@'10.0.0.%' has access to the 'bugsy' DB.
最佳答案
接受的答案只是重命名了用户,但权限被留下了。
我建议使用:
RENAME USER 'foo'@'1.2.3.4' TO 'foo'@'1.2.3.5';
根据MySQL documentation :
RENAME USER causes the privileges held by the old user to be those held by the new user.
https://stackoverflow.com/questions/1913984/