How to grant remote access to MySQL for a whole subnet?

前端 未结 7 1779
不知归路
不知归路 2020-12-02 07:50

I can easily grant access to one IP using this code:

$ mysql -u root -p
Enter password:    
mysql> use mysql    
mysql> GRANT ALL ON *.* to root@\'192.         


        
7条回答
  •  天命终不由人
    2020-12-02 08:23

    Just a note of a peculiarity I faced:
    Consider:

    db server:  192.168.0.101
    web server: 192.168.0.102
    

    If you have a user defined in mysql.user as 'user'@'192.168.0.102' with password1 and another 'user'@'192.168.0.%' with password2,

    then,

    if you try to connect to the db server from the web server as 'user' with password2,

    it will result in an 'Access denied' error because the single IP 'user'@'192.168.0.102' authentication is used over the wildcard 'user'@'192.168.0.%' authentication.

提交回复
热议问题