文档

通过DMS登录MySQL提示“Host'xxx.xxx.xxx.xxx'is not allowed to connect to this MySQL server”错误

更新时间:

问题描述

通过DMS数据管理以指定数据库用户名登录数据库时,出现“null, message from server: Host ‘xxx.xxx.xxx.xxx’ is not allowed to connect to this MySQL server”报错。

问题原因

数据库的mysql.user表中设置指定用户只能从本机登录MySQL,导致指定数据库的用户无法远程登录MySQL。

解决方案

说明

阿里云提醒您:

  • 如果您对实例或数据有修改、变更等风险操作,务必注意实例的容灾、容错能力,确保数据安全。

  • 如果您对实例(包括但不限于ECS、RDS)等进行配置与数据修改,建议提前创建快照或开启RDS日志备份等功能。

  • 如果您在阿里云平台授权或者提交过登录账号、密码等安全信息,建议您及时修改。

  1. 在数据库的本地机器中,使用命令行或者客户端工具登录MySQL数据库。

  2. 创建可以远程登录MySQL的数据库用户。不同网络环境中,授权的网段不同,请参考以下内容:

    • 经典网络在经典网络环境中,创建可以远程登录MySQL数据库用户的SQL语句如下所示。

      grant all privileges on *.* to 'dms'@'120.55.177.0/24' identified by '[$Password]';
      grant all privileges on *.* to 'dms'@'121.43.18.0/24' identified by '[$Password]';
      grant all privileges on *.* to 'dms'@'10.153.176.106/24' identified by '[$Password]';
      grant all privileges on *.* to 'dms'@'10.137.42.136/24' identified by '[$Password]';
      说明

      说明

      • [$Password]是您为数据库用户设置的密码。

      • 本操作涉及的网段为阿里云经典网络专用网段。

    • VPC网络在VPC网络环境中,创建可以远程登录MySQL数据库用户的SQL语句如下所示。

      grant all privileges on *.* to 'dms'@'100.104.175.0/24' identified by '[$Password]';
      grant all privileges on *.* to 'dms'@'100.104.72.0/24' identified by '[$Password]';
      grant all privileges on *.* to 'dms'@'100.104.5.0/24' identified by '[$Password]';
      grant all privileges on *.* to 'dms'@'100.104.205.0/24' identified by '[$Password]';
      说明
      • [$Password]是您为数据库用户设置的密码。

      • 本操作涉及的网段为阿里云VPC网络专用网段。

适用于

  • 数据管理DMS

  • 云数据库RDS MySQL版

  • 本页导读 (1)
文档反馈