在 docker 里面启动了 MySQL 8.0 版本数据库容器,出现了 报错: ERROR 1410 (42000): You are not allowed to create a user with GRANT 。一查日志显示是 ” “Error 1130: Host ‘172.17.0.1’ is not allowed to connect to this MySQL server“。
于是进入容器
docker exec -it mysql-project mysql -uroot -p
输入密码。查看数据库连接实例的配置,发现 host 配置是 localhost ,想着重新授权一下。grant 命令改授权的 host 时,
grant all on book.* to 'book'@'%';
报错 【ERROR 1410 (42000): You are not allowed to create a user with GRANT】了。
然后尝试改一下:
mysql> grant all on book.* to ‘book’@’%’;
ERROR 1410 (42000): You are not allowed to create a user with GRANT
mysql> update user set host=”%” where user=’book’;
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> grant all privileges on book.* to ‘book’@’%’;
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
没限定 host 确实不太好。但是这样工作哈。