蚂蚁无法连接到MySQL(拒绝访问),但MySQL客户端可能 [英] Ant couldn't connect to mysql (access denied), but mysql client could

查看:320
本文介绍了蚂蚁无法连接到MySQL(拒绝访问),但MySQL客户端可能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我哈瓦接下来的任务在我的Ant文件:

I hava the next task in my ant file:

<target name="initdb">  
  <sql driver="com.mysql.jdbc.Driver"
       url="jdbc:mysql://localhost:3306/dtest"
       userid="root" password="oksaoksaoksa" >
    <classpath>
      <pathelement path="./lib/mysql-connector-java-5.1.13-bin.jar"/>      
    </classpath>
    <transaction  src="./init.sql"/>
  </sql>
</target>

当我运行它,我看到了错误:

When I run it, I see the error:

BUILD FAILED
/home/sbos/projects/texterra-tests/deploy.xml:43: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

不过,我可以用mysql客户端等登录名和密码登录:

However, I can login with such login and password with mysql client:

mysql -u root -p
Enter password: <oksaoksaoksa>
Welcome to the MySQL monitor.  Commands end with ; or \g.
...

为什么出现这种情况?我刚刚安装的MySQL在Ubuntu 10.10如果该事项

Why this happens? I've just installed mysql in ubuntu 10.10 if that matters

推荐答案

这是因为,当你通过mysql客户端本地主机连接,它使用Unix套接字连接,它处理权限有些不同,而蚂蚁所连接到本地主机通过TCP / IP。

It happens because when you connect through localhost in the mysql client, it uses the unix socket to connect, which handles privileges a bit different, while ant connects to localhost through tcp/ip.

尝试授予访问127.0.0.1(这是不一样的为localhost至于MySQL服务器而言)

Try granting access to 127.0.0.1 (which is not the same as localhost as far as the mysql server is concerned)

grant all on initdb.* to 'root'@'127.0.0.1' identified by 'oksaoksaoksa';

这篇关于蚂蚁无法连接到MySQL(拒绝访问),但MySQL客户端可能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆