mysql拒绝访问怎么办
1、1) 如果你登录数据库提示: java.sql.SQLException: null, message from server: "Host 刻八圄俏9;xxx' is not allowed to connect to this MySQL server"表示该对象不是远程对象,不能通过该对象远程访问数据解决方法: 1. 改表方法use mysql ;select user,host,password from user;update user set host = '%' where user='root'; 2.授权修改例如: 你想XHN使用mypassword从任何主机连接到mysql服务器的话。 GRANT ALL PRIVILEGES ON *.* TO 'XHN'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION; 如果你想允许用户XHN从ip为192.168.12.36的主机连接到mysql服务器,并使用mypassword作为密码。 GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.12.36' IDENTIFIED BY 'mypassword' WITH GRANT OPTION; MySQL默认只支持本机访问,若要实现网络访问,则要把源计算机的IP更新到user表中。
2、2) 提示:Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'表示同一个ip在短时间内产生太多(超过mysql数据库短时间链接的最大值)中断的数据库连接而导致的阻塞;解决方法: 1. 提高允许的max_connection_errors数量(只能解决单次,解决表面问题): ① 进入Mysql数据库查看max_connection_errors:show variables like '%max_connect_errors%'; ② 修改max_connection_errors的数量为1000:set global max_connect_errors = 1000; ③ 查看是否修改成功:show variables like '%max_connect_errors%';(如图123) 2. 使用mysqladmin flush-hosts命令清理一下hosts文件(不知道mysqladmin在哪个目录下可以使用命令查找:whereis mysqladmin 即可); ① 在查找到的目录下使用命令修改:/usr/bin/mysqladmin flush-hosts -h192.168.1.1-P3308-uroot-prootpwd; 备注: 其中端口号,用户名,密码根据需要自己情况来添加或修改; 配置有master/slave主从数据库的要把主库和从库都修改一遍的; 也可以在数据库中进行,命令:flush hosts;(最后一张图)
3、提示:Host 192.168.12.36 is not allowed to connect to this MySQL serverConnection closed byforeign这常见于安装了mysql,然后用 telnet ip 3306,端口报错解决办法:mysql>UPDATE mysql.user SET Host=% WHERE Host=localhost;mysql>GRANT ALL PRIVILEGES ON *.* TOroot@"%" ;mysql>FLUSH PRIVILEGES;
4、提示:mysql_java.sql.SQLException: null, message from server: "Host 'xxx' is not allowed to connect1 进入你的数据库$ /usr/local/mysql/bin/mysql -u root -p按Ener,输入你的密码2 成功进入之后依次操作mysql> user mysql;mysql> use mysql;mysql> select host from user;mysql> update user set host ='%' where user ='root';mysql> exit;退出MySql模式最后重新启动mysql服务就搞定
5、提示:net start mysql(如图)问题是mysql安装之后,没有在命令行里执行mysqlinstall如果报错service存在,则需要先remove掉,然后再次执行mysqlinstall,最后netstartmysql即可解决
6、有些无法访问是运行环境没有配置好或是物理故障,请排除物理故障(如网线,电源线之类故障)