一、进入系统,连接上MySQL
这里的admin是你自己数据库中设置的用户名,要根据实际情况填写,然后回车键后输入数据库的密码(注意:密码不会显示,输入之后直接回车即可)
[root@VM-0-16-centos ~]# mysql -u admin -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 261
Server version: 5.7.30-log MySQL Community Server (GPL)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
二、查看用户表
1、首先要指定使用mysql数据库,然后进行查询操作
//指定数据库
mysql> use mysql;
Database changed
mysql> select Host,User from user;
三、更新和授权用户表
1、更新和授权用户
//更新用户表
mysql> update `user` set `Host`='125.70.*.*' where `Host`='125.70.*.*';
//授权用户表
grant all privileges on *.* to 'root'@'125.70.*.*' identified by 'password' with grant option;
125.70.*.是允许远程访问的IP的值,root是账户名,后面的password是密码。
即,允许来自125.70…连接并使用root账户和password这个密码进行访问。
ALL PRIVILEGES ON 后面的.*表示所有数据库,即完全访问权限,可以指定为特定数据库。
如果允许所有ip访问,则ip可以用%代替。
2、刷新(注意:需刷新之后才能生效)
//强制刷新
mysql> flush privileges;
经过上面的一番操作,就可以成功连接了!!!
参考博客:https://blog.youkuaiyun.com/u014026084/article/details/79363408