2017-07-02 128 views
0

遠程連接,我知道命令的MySQL允許從多個IP地址

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

這將允許從IP 1.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; 

或者這是不允許的?

回答

0

您可以多次運行上述命令來授予來自多個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; 

所有IPS

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

隨着MySQL的通配符。 而不是使用有限的數字,你可以實現一個通配符。這可以通過添加'%'而不是數字來完成。