使用XAMPP的mysql和自行下载的mysql不能远程连接问题

1、本地的mysql

  • 改表法
  1. 使用命令行修改
    登录mysql:mysql -u root -p
    使用mysql数据库:mysql>use mysql
    修改权限配置:mysql>update user set host = ’%’ where user = ’root’;mysql>select host, user from user;
    更新状态:mysql>flush privileges;
  2. 使用Navicat修改
    登录Navicat,选择mysql数据库中的user表,添加一条权限用户名:自起(root或者任意),主机名:%,其他参考 localhost - root这一行。
  • 授权法

    如果你想root使用password从任何主机连接到mysql服务器的话
    使用:
    mysql>GRANT ALL PRIVILEGES ON *.* TO ’root’@’%’ IDENTIFIED BY ’password’ WITH GRANT OPTION;
    mysql>flush privileges;

2、XAMPP中的mysql

  • 修改mysql\bin\my.ini文件,找到# bind-address="127.0.0.1"这一行,改成# bind-address=“0.0.0.0”

  • 修改phpMyAdmin\config.inc.php文件,找到
    /* Authentication type and info */
    $cfg['Servers'][$i]['auth_type'] = 'config';
    $cfg['Servers'][$i]['user'] = 'root';
    $cfg['Servers'][$i]['password'] = '';
    $cfg['Servers'][$i]['extension'] = 'mysql';
    $cfg['Servers'][$i]['AllowNoPassword'] = true;
    修改成:
    /* Authentication type and info */
    $cfg['Servers'][$i]['auth_type'] = 'cookie';
    $cfg['Servers'][$i]['user'] = 'root';
    $cfg['Servers'][$i]['password'] = 'root';
    $cfg['Servers'][$i]['extension'] = 'mysql';
    $cfg['Servers'][$i]['AllowNoPassword'] = true;

  • 重新启动mysql和Apache

1、进入phpmyadmin管理界面首页,点击“账户”后,再“添加新用户”,用户名:root(随意),主机:%(必须是%),对应的密码可以设置可以不设置,即可开通远程连接;
2、或者用工具Navicat链接到本地数据,点击“管理用户”,添加用户进行设置。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值