1、在linux上登录到mysql容器中
进入mysql容器:
[root@iZ2vc18c96x3s97qf6t3ckZ ~]# docker exec -it mysql5 /bin/bash
mysql登录:
root@4080bca66b75:/# mysql -u root -p
Enter password:
2、查看当前root用户的权限
mysql> show grants;
+---------------------------------------------------------------------+
| Grants for root@localhost |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
2 rows in set (0.00 sec)
3、为root@%用户授权
mysql> grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)
4、退出容器后将容器进行重启