CentOS7开启MySQL远程登录

  • 登录mysql数据库
mysql -u root -p '你的密码'
  • 查看user表
mysql> use mysql;
mysql> select Host,User,Password from user;
ERROR 1054 (42S22): Unknown column 'Password' in 'field list'
mysql> select Host,User from user;
+-----------+---------------+
| Host      | User          |
+-----------+---------------+
| localhost | mysql.session |
| localhost | mysql.sys     |
| localhost | root          |
+-----------+---------------+

#Host主机,User用户
  • 开启远程访问权限
mysql>  grant all privileges  on *.* to root@'%' identified by "你的mysql密码";
Query OK, 0 rows affected, 1 warning (0.00 sec)

#%代表所有主机,也可以写ip地址
  • 重新加载权限数据
mysql>  flush privileges;    #重新加载权限数据
Query OK, 0 rows affected (0.00 sec)
  • 之后就可以远程连接了
posted @ 2021-05-09 23:10  手可摘星辰/*  阅读(433)  评论(0编辑  收藏  举报