sqlexception导出到mysql时pig出现jdbc错误

xurqigkl  于 2021-06-02  发布在  Hadoop
关注(0)|答案(1)|浏览(338)

有人能帮我解决这个问题吗?我正在尝试将pig结果导出到mysql,但是我遇到了用户拒绝访问的问题。用户名和密码绝对正确。
这是我的Pig剧本:

REGISTER 'hdfs:///home/mysql-connector-java-3.1.14-bin.jar';
REGISTER 'hdfs:///home/piggybank-0.12.0.jar';

test = LOAD '/home/data.csv' USING PigStorage(',') AS (nom1:chararray, nom2:chararray, nom3:float, nom4:chararray);

processedtest = FOREACH test GENERATE nom1, nom2, nom3, nom4;

STORE processedtest INTO 'table' USING org.apache.pig.piggybank.storage.DBStorage('com.mysql.jdbc.Driver', 'jdbc:mysql://localhost/test', 'root',  'root', 'INSERT INTO table (nom1, nom2, nom3, nom4) VALUES (?, ?, ?, ?)');

这是日志文件中的错误:

Pig Stack Trace
---------------
ERROR 2997: Encountered IOException. JDBC Error

java.io.IOException: JDBC Error
    at org.apache.pig.piggybank.storage.DBStorage.prepareToWrite(DBStorage.java:298)
    at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigOutputFormat$PigRecordWriter.<init>(PigOutputFormat.java:125)
    at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigOutputFormat.getRecordWriter(PigOutputFormat.java:86)
    at org.apache.hadoop.mapred.ReduceTask.runNewReducer(ReduceTask.java:597)
    at org.apache.hadoop.mapred.ReduceTask.run(ReduceTask.java:444)
    at org.apache.hadoop.mapred.Child$4.run(Child.java:268)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:396)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1408)
    at org.apache.hadoop.mapred.Child.main(Child.java:262)
Caused by: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2975)

这是我的mysql状态:我可以向您保证我使用了密码“root”来访问它:

Connection id:          6
Current database:
Current user:           root@localhost
SSL:                    Not in use
Using delimiter:        ;
Server version:         5.5.37 MySQL Community Server (GPL)
Protocol version:       10
Connection:             localhost via TCP/IP
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    latin1
Conn.  characterset:    latin1
TCP port:               3306
Uptime:                 5 hours 46 min 49 sec

我仍然是一个新手,所以建议我任何其他方法,是有益的,更有效的时候导出到mysql。

bmvo0sr5

bmvo0sr51#

在您的消息中,用户“root”@“localhost”(使用密码:yes)的访问被拒绝,您使用的密码不正确。

相关问题