最近将项目移到品高云和阿里云遇到的问题数据库问题。
java.sql.SQLException: null, message from server: "Host 'xxx' is not allowed to connect to this MySQL server":
java.sql.SQLException: Access denied for user 'root'@'xxx.xxx.xxx.xxx' at (数据库名)
表示该对象不是远程对象,不能通过该对象远程访问数据
解决:
方案一:改表:
use mysql ;select user,host,password from user;
update user set host = '%' where user='root';
方案二:授权法:
例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
无论使用哪种方案,请重启Mysql服务。
相关推荐
java.sql.SQLException: null, message from server: “Host ‘223.72.41.7’ is not allowed to connect to this MySQL server” 客户端访问时报错: 解决方法: 1,登陆服务器 mysql> use mysql; //用mysql ...
用 Navicat 配置远程连接 MySQL 数据库时遇到报错信息 1130 - Host XXX is not allowed to connect to this MySQL server 解决方法: 首先,登录 root 用户: `use mysql;` 然后,查看 root 用户的 host: `...
MySQL数据库在运行过程中可能会遇到各种错误,其中错误代码1103表示“Host ‘xxx’ is not allowed to connect to this MySQL server”,这是一个典型的权限问题,意味着指定的主机尝试连接MySQL服务器时,没有被...
在使用 Navicat 连接 MySQL 数据库时,如果遇到类似 `ERROR 1130: Host xxx.xxx.xxx.xxx is not allowed to connect to this MySQL server` 的错误,通常是因为 MySQL 的访问控制列表没有正确配置。 **解决方法:**...
MySQL数据库在运行过程中可能会遇到各种错误,其中错误代码1103表示“Host ‘xxx’ is not allowed to connect to this MySQL server”,这是一个典型的权限问题,意味着指定的主机尝试连接MySQL服务器时,其权限未...
- **问题1**:在使用`mysql -uusername -p`命令登录MySQL时出现“Host 'xxx.xxx.xxx.xxx' is not allowed to connect to this MySQL server”的错误提示。 - **解决方法**:这是因为MySQL服务器没有设置允许该IP...
2. **配置远程访问权限**:如果出现 “Host 'XXX' is not allowed to connect to this MySQL server” 错误,需要开启 MySQL 的远程访问权限: - 在命令行中进入 MySQL 的 bin 目录,执行 `mysql -u root -p` 登录 ...
$conn = mysql_connect("localhost", "my_user", "my_pass"); $db = mysql_select_db("world"); $result = mysql_unbuffered_query("SELECT Name FROM City"); if ($result) { while ($row = mysql_fetch_assoc($...