<article>
<h1 class="csdn_top">java.sql.SQLException: null, message from server: “Host ‘xxx’ is not allowed to connect</h1>
<div class="article_bar clearfix">
<div class="artical_tag">
<span class="original">原创</span>
<span class="time">2015年12月23日 10:32:20</span>
</div>
<ul class="article_tags clearfix csdn-tracking-statistics" data-mod="popu_377" style="display: none;">
<li class="tit">标签:</li>
</ul>
<ul class="right_bar">
<li><button class="btn-noborder"><i class="icon iconfont icon-read"></i><span class="txt">3164</span></button></li>
<!--<li><button class="btn-noborder"><i class="icon iconfont icon-dashang-"></i><span class="txt">0</span></button></li>-->
<li class="edit" style="display: none;">
<a class="btn-noborder" href="http://write.blog.csdn.net/postedit/50385057">
<i class="icon iconfont icon-bianji"></i><span class="txt">编辑</span>
</a>
</li>
<li class="del" style="display: none;">
<a class="btn-noborder" οnclick="javascript:deleteArticle(fileName);return false;">
<i class="icon iconfont icon-shanchu"></i><span class="txt">删除</span>
</a>
</li>
</ul>
</div>
<div id="article_content" class="article_content csdn-tracking-statistics" data-mod="popu_519" data-dsm="post">
<p><span style="font-size:12px"><span style="white-space:pre"></span>因为公司需要把项目和数据库分开进行,所以有2台服务器,直接修改连接池ip后,出现了</span><span style="font-size:12px; font-family:'Microsoft YaHei',微软雅黑,Arial,'Lucida Grande',Tahoma,sans-serif; line-height:22px">ava.sql.SQLException:
null, message from server: “Host ‘xxx’ is not allowed to connect这样的错误,它的意思就是安装了数据库的服务器不允许部署项目的服务器进行远程连接。也就是权限问题,修改权限就可以了,修改方法是。</span></p>
<p><span style="font-size:12px; font-family:'Microsoft YaHei',微软雅黑,Arial,'Lucida Grande',Tahoma,sans-serif; line-height:22px"><span style="white-space:pre"></span>找到user表,这个可以通过工具找,因为我的远程连接工具是Navicat,user表就在这里<img src="https://img-blog.csdn.net/20151223103730674?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">打开user表,<img src="https://img-blog.csdn.net/20151223103819026?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">比如我这里项目用的用户名是bjtf,那么就把bjtf的Host改成%,就可以了,之后还要执行一下执行刷新权限:flush
privileges(它的执行就像sql语句一样执行就可以了);步骤也可以这样操作:</span></p>
<p><span style="font-family:'Microsoft YaHei',微软雅黑,Arial,'Lucida Grande',Tahoma,sans-serif; line-height:22px"><span style="font-size:12px">在mysql的bin目录下执行:mysql -uroot -p密码 登陆到数据:<br>
执行use mysql;<br>
select host,user,password from user;<br>
可以看到user为root,host为localhost的话,说明mysql只允许本机连接,那么外网,本地软件客户端就无法连接了。<br>
调整方法:<br>
执行:update user set host='%' where user ='root';<br>
执行刷新权限:flush privileges;<br>
可以测试外网连接mysql服务器。</span><br>
</span></p>
<p><span style="font-size:12px; font-family:'Microsoft YaHei',微软雅黑,Arial,'Lucida Grande',Tahoma,sans-serif; line-height:22px"><span style="white-space:pre"></span></span></p>
<div><span style="font-size:12px; font-weight:normal"><span style="white-space:pre"></span></span></div>
<link rel="stylesheet" href="http://static.blog.csdn.net/public/res-min/markdown_views.css?v=2.0">
</div>
</article>
java.sql.SQLException: null, message from server: “Host ‘xxx’ is not allowed to connect
最新推荐文章于 2022-09-26 20:07:10 发布