#5.5~5.6
–宿主机登陆容器mysql
[root@centos7 ~]# mysql -uroot -proot -h172.18.12.9 -P3506
mysql> select user,host,grant_priv,super_priv,password from mysql.user;
mysql> select user();
mysql> delete from mysql.user where host=’%’ limit 1;
mysql> flush privileges;
如何创建远程登陆?
[root@mysqlhost02 /]# mysql -uroot -proot --本地登陆
mysql> grant all on . to root@’%’ identified by ‘root’ with grant option;
mysql> flush privileges;
备注:
1.set password for root@’%’=password(‘root’); --修改密码
2.mysql用户+host才是一个真正的用户
#5.7
[root@centos7 ~]# mysql -uroot -proot -h172.18.12.9 -P3508
mysql> select user,host,grant_priv,super_priv,authentication_string,password_last_changed from mysql.user;
mysql> update mysql.user set authentication_string=password(‘root’) where user=‘root’;
mysql> flush privileges;
#8.0
[root@centos7 ~]# mysql -uroot -proot -h172.18.12.9 -P3509
ERROR 1130 (HY000): Host ‘172.18.1.1’ is not allowed to connect to this MySQL server --提示无法登陆
mysql> select user,host,grant_priv,super_priv,authentication_string,password_last_changed from mysql.user;
处理方法:先创建用户,在给用户给权限
mysql> create user root@’%’ identified with mysql_native_password by ‘root’;
mysql> grant all on . to root@’%’ with grant option;
mysql> flush privileges;
[root@centos7 ~]# mysql -uroot -proot -h172.18.12.9 -P3509
mysql> alter user root@‘localhost’ identified with mysql_native_password by ‘root’; --更改密码