ITPub博客

首页 > 数据库 > MySQL > MySQL修改密码和远程登录

MySQL修改密码和远程登录

原创 MySQL 作者:wddwr7307914 时间:2021-03-13 23:56:21 0 删除 编辑

#5.5~5.6
[root@centos7 ~]# mysql -uroot -proot -h172.18.12.9 -P3506     --宿主机登陆容器mysql
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';   --更改密码

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69947868/viewspace-2762747/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
中国DBA联盟(ACDU)成员,Oracle PostgreSQL ACE,CSDN博客专家及B站知名UP主,全网粉丝10万+,目前服务于工业互联网,擅长主流Oracle、MySQL、PG、高斯及Greenplum备份恢复,安装迁移,性能优化、故障应急处理。

注册时间:2020-06-13

  • 博文量
    203
  • 访问量
    213265