Host is not allowed to connect to this MySQL server解决方法

docker exec -it mysql5.7 bash  

mysql -uroot -p

  1. 执行use mysql;
  2. 执行update user set host = '%' where user = 'root';这一句执行完可能会报错,不用管它。
  3. 执行FLUSH PRIVILEGES;