蚂蚁无法连接到MySQL(拒绝访问),但MySQL客户端可能(Ant couldn't co

2019-11-04 07:42发布

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

<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>

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

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

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

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

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

Answer 1:

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

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

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


文章来源: Ant couldn't connect to mysql (access denied), but mysql client could
标签: mysql ant