2
任何人都可以幫我解決這個問題嗎?我正在試圖將mysql結果導出到mysql,但是我遇到了拒絕訪問用戶的問題。用戶名和密碼絕對正確。SQLException。導出爲mysql時使用PIG時的JDBC錯誤
這是我的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的狀態:我可以向你保證,我用的密碼「根」來訪問它:
Connection id: 6
Current database:
Current user: [email protected]
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。