我知道命令
GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'1.2.3.4' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
这将允许来自ip 1.2.3.4
的远程连接,但如果我想允许来自1.2.3.4
和5.6.7.8
的连接怎么办?
它看起来像这样吗?
GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'1.2.3.4, 5.6.7.8' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
或者这是不允许的?
答案 0 :(得分:3)
您可以多次运行上述命令以从多个IP进行GRANT访问。
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;
到所有ips
mysql> GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
答案 1 :(得分:0)
使用MySQL通配符。 而不是使用有限的数字,您可以实现通配符。这可以通过添加'%'来完成。而不是数字。