我知道这个命令

GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'1.2.3.4' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;

这将允许从ip1.2.3.4进行远程连接,但是如果我希望同时允许从1.2.3.45.6.7.8进行连接,那会怎么样?
会是这样吗?
GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'1.2.3.4, 5.6.7.8' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;

或者这是不允许的?

最佳答案

您可以多次运行上面的命令来授予来自多个IP的访问权限。

mysql> GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'1.2.3.4' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'5.6.7.8' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;

所有IP
mysql> GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;

关于mysql - MySQL允许来自多个IP地址的远程连接,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44866698/

10-11 09:08