无法从java连接到MySQL数据库,但能够从普通的MySQL命令行连接

时间:2017-11-06 20:08:50

标签: mediawiki mamp-pro wiktionary

我尝试使用 mwdumper jar将wiki迅速转储导入到我使用MAMP Pro创建的数据库中。这是我挣扎的命令:

java -jar mwdumper-1.25.jar --format=sql:1.5 /Users/med/Downloads/enwiktionary-20171001-pages-articles-multistream.xml --output=mysql://localhost:8889/wiktionay?user=wikiuser&password=wiki2017

使用此命令运行jar提供以下内容:

> [1] 1209
$ Exception in thread "main" java.io.IOException: Access denied for user 'wikiuser'@'localhost' (using password: NO)
        at org.mediawiki.dumper.Dumper.connectMySql(Dumper.java:225)
        at org.mediawiki.dumper.Dumper.openOutputFile(Dumper.java:211)
        at org.mediawiki.dumper.Dumper.main(Dumper.java:96)
Caused by: java.sql.SQLException: Access denied for user 'wikiuser'@'localhost' (using password: NO)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4074)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4006)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:919)
        at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1694)
        at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1244)
        at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2397)
        at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2430)
        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2215)
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:813)
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:334)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:270)
        at org.mediawiki.dumper.Dumper.connectMySql(Dumper.java:221)
        ... 2 more

当我只是尝试从终端连接到数据库时,我没有访问问题:

$ /Applications/MAMP/Library/bin/mysql -u wikiuser -p

正如相关问题所述,我检查了“#34;允许网络访问MySQL&#34;从MAMP界面,但它仍然没有帮助。使用root也是同样的问题。

知道什么是错的吗?

1 个答案:

答案 0 :(得分:2)

问题是,由于&amp; 运算符密码,因此在终端上发送URL时,URL会作为单独的命令获取。因此,mysql永远不会得到密码

使用 \ 转义&amp; ,即。

--output=mysql://localhost:8889/wiktionay?user=wikiuser\&password=wiki2017

编辑:04:14 AM,IST

  

线程中的异常&#34; main&#34; java.lang.IllegalArgumentException异常:   预期的文件流,得到SQL连接?

尝试在结尾传递流文件名,即 - 输出后跟 - 格式然后/Users/med/Downloads/enwiktionary-20171001-pages-articles-multistream.xml