CentOS下配置MySQL允许root用户远程登录

来源:互联网 发布:图知天下 编辑:程序博客网 时间:2024/05/16 19:29

在CentOS上成功安装MySQL Server后,发现无法用客户端进行连接,查阅相关质料后发现如果想让root用户支持远程登录,是需要进行额外配置的;配置步骤如下:

步骤:

  1. 修改root密码 (可选)

    # 切换到mysql这个数据库mysql> use mysql;# 将root用户的密码修改为:123456mysql> update user set password=PASSWORD('123456') where user='root';
  2. 检查root配置

    # root用户登录$ mysql -u root -p# 切换到mysql这个数据库mysql> use mysql;# 查看root用户配置mysql> select host,user from user where user='root';
  3. 修改root配置

    如果查询结果中不包含以下记录,请添加,否则请忽略次步骤

    host user % root

    mysql> update user set host = ‘%’ where user = ‘root’ and host=’127.0.0.1’;

  4. 给用户授权

    mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
  5. 使配置生效

    mysql> flush privileges;

配置完成,客户端重新登录成功;

0 0
原创粉丝点击