Support Questions

Find answers, ask questions, and share your expertise

Accessing Mysql DB on my Mac via Sqoop

avatar
Contributor

Hi,

I am trying to perform the following task: 'Import data from a table in a relational database into HDFS'.

To get a working example of this - I have created a mySQL database (hostname=127.0.0.1 and port=xxxx) on my Mac.

I have then logged in to ssh (http://127.0.0.1:4200/) root within a terminal and type:

sqoop list-databases --connect jdbc:mysql://127.0.0.1:xxxx --username root --password abcabcabc

Instead of a list of databases, I get the below output. Can anyone advise?

Warning: /usr/hdp/2.3.2.0-2950/accumulo does not exist! Accumulo imports will fail.        
Please set $ACCUMULO_HOME to the root of your Accumulo installation.                      
16/01/11 18:44:42 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6.2.3.2.0-2950              
16/01/11 18:44:42 WARN tool.BaseSqoopTool: Setting your password on the command-line is ins
ecure. Consider using -P instead.                                                          
16/01/11 18:44:43 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset. 
SLF4J: Class path contains multiple SLF4J bindings.                                        
SLF4J: Found binding in [jar:file:/usr/hdp/2.3.2.0-2950/hadoop/lib/slf4j-log4j12-1.7.10.jar
!/org/slf4j/impl/StaticLoggerBinder.class]                                                
SLF4J: Found binding in [jar:file:/usr/hdp/2.3.2.0-2950/zookeeper/lib/slf4j-log4j12-1.6.1.j
ar!/org/slf4j/impl/StaticLoggerBinder.class]                                              
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.          
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]                      
16/01/11 18:44:43 ERROR manager.CatalogQueryManager: Failed to list databases              
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)    
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)                  
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)                      
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)                      
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:935)                      
        at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4101)                        
        at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1300)                          
        at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2337)            
        at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2370)      
        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2154)            
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792)                  
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)                  
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)          
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorI
mpl.java:57)                                                                              
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorA
ccessorImpl.java:45)                                                                      
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)                
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)                            
        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)              
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)      
        at java.sql.DriverManager.getConnection(DriverManager.java:571)                    
        at java.sql.DriverManager.getConnection(DriverManager.java:215)                    
        at org.apache.sqoop.manager.SqlManager.makeConnection(SqlManager.java:885)        
        at org.apache.sqoop.manager.GenericJdbcManager.getConnection(GenericJdbcManager.jav
a:52)                                                                                      
        at org.apache.sqoop.manager.CatalogQueryManager.listDatabases(CatalogQueryManager.j
ava:57)                                                                                    
        at org.apache.sqoop.tool.ListDatabasesTool.run(ListDatabasesTool.java:49)          
        at org.apache.sqoop.Sqoop.run(Sqoop.java:148)                                      
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)                      
        at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:184)                                
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:226)                                  
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:235)                                  
        at org.apache.sqoop.Sqoop.main(Sqoop.java:244)                                    
16/01/11 18:44:43 ERROR sqoop.Sqoop: Got exception running Sqoop: java.lang.RuntimeExceptio
n: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)  
java.lang.RuntimeException: java.sql.SQLException: Access denied for user 'root'@'localhost
' (using password: YES)                                                                    
        at org.apache.sqoop.manager.CatalogQueryManager.listDatabases(CatalogQueryManager.j
ava:73)                                                                                    
        at org.apache.sqoop.tool.ListDatabasesTool.run(ListDatabasesTool.java:49)          
        at org.apache.sqoop.Sqoop.run(Sqoop.java:148)                                      
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)                      
        at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:184)                                
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:226)                                  
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:235)                                  
        at org.apache.sqoop.Sqoop.main(Sqoop.java:244)                                    
Caused by: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password
: YES)                                                                                    
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)                  
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)                      
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)                      
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:935)                      
        at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4101)                        
        at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1300)                          
        at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2337)            
        at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2370)      
        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2154)            
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792)                  
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)                  
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)          
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorI
mpl.java:57)                                                                              
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorA
ccessorImpl.java:45)                                                                      
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)                
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)                            
        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)              
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)      
        at java.sql.DriverManager.getConnection(DriverManager.java:571)                    
        at java.sql.DriverManager.getConnection(DriverManager.java:215)                    
        at org.apache.sqoop.manager.SqlManager.makeConnection(SqlManager.java:885)        
        at org.apache.sqoop.manager.GenericJdbcManager.getConnection(GenericJdbcManager.jav
a:52)                                                                                      
        at org.apache.sqoop.manager.CatalogQueryManager.listDatabases(CatalogQueryManager.j
ava:57)                                                                                    
        ... 7 more                            
1 ACCEPTED SOLUTION

avatar
Master Mentor
@Revlin Abbi

try this : grant all privileges on *.* to 'root'@'localhost' identified by 'abcabcabc' with grant option;

sqoop list-databases --connect jdbc:mysql://127.0.0.1:xxxx --username root --password abcabcabc

root user does not have read/list permissions.

ERROR manager.CatalogQueryManager: Failed to list databases java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

View solution in original post

11 REPLIES 11

avatar
Master Mentor

@Revlin Abbi has this been resolved? Can you post your solution or accept best answer?

avatar
New Contributor

We had the same issue, the MySQL was hosted in Google CloudSQL, the issue was that there was some syntax error and sqoop kept complaining about permissions. Once we fixed the syntax it started working, the command is : sqoop list-databases --connect jdbc:mysql://{google cloudsql ipaddress} --username {username} --password {pwd} . Another way to isolate if this is a Sqoop issue or db connectivity issue is to try and import the table instead of listing the databases, also not listing databases needs additional permission.