How to restrict certain ip access to mysql

I hope that only 172.29.8.72 and 192.168.3.39 can be connected to a user in mysql. How should I set it?

Aug.24,2021

specify ip


GRANT ALL PRIVILEGES ON *.* TO 'username'@'172.29.8.72' IDENTIFIED BY 'password' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'username'@'192.168.3.39' IDENTIFIED BY 'password' WITH GRANT OPTION;
flush privileges;

`CREATE USER 'root'@'172.29.8.72' IDENTIFIED BY' yourpass';
GRANT ALL PRIVILEGES ON . When TO 'root'@'172.29.8.72';-sharp modifies permissions, add WITH GRANT OPTION
CREATE USER' root'@'192.168.3.39' IDENTIFIED BY 'yourpass';
GRANT ALL PRIVILEGES ON . TO' root'@'192.168.3.39';
flush privileges; `

Menu