Support Questions

Find answers, ask questions, and share your expertise

Import all tables from MySQL to HIVE using SQOOP



  Following command is the one which I tried to import all tables from MySQL to HIVE but it seems i am doing wrong somewhere. can anyone please help me to solve this?


sqoop import-all-tables --connect jdbc:mysql://localhost/forhive --username root  -P  --m 1 --hive-import --hive-database default --warehouse-dir /user/forhive --driver com.mysql.jdbc.Driver


Warning: /usr/lib/sqoop/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
19/12/03 23:36:09 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6-cdh5.13.0
Enter password:
19/12/03 23:36:16 INFO tool.BaseSqoopTool: Using Hive-specific delimiters for output. You can override
19/12/03 23:36:16 INFO tool.BaseSqoopTool: delimiters with --fields-terminated-by, etc.
19/12/03 23:36:16 WARN sqoop.ConnFactory: Parameter --driver is set to an explicit driver however appropriate connection manager is not being set (via --connection-manager). Sqoop is going to fall back to org.apache.sqoop.manager.GenericJdbcManager. Please specify explicitly which connection manager should be used next time.
19/12/03 23:36:16 INFO manager.SqlManager: Using default fetchSize of 1000
19/12/03 23:36:16 ERROR manager.SqlManager: Error reading database metadata: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(
at com.mysql.jdbc.MysqlIO.checkErrorPacket(
at com.mysql.jdbc.MysqlIO.checkErrorPacket(
at com.mysql.jdbc.MysqlIO.checkErrorPacket(
at com.mysql.jdbc.MysqlIO.secureAuth411(
at com.mysql.jdbc.MysqlIO.doHandshake(
at com.mysql.jdbc.ConnectionImpl.coreConnect(
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(
at com.mysql.jdbc.ConnectionImpl.createNewIO(
at com.mysql.jdbc.ConnectionImpl.<init>(
at com.mysql.jdbc.JDBC4Connection.<init>(
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
at java.lang.reflect.Constructor.newInstance(
at com.mysql.jdbc.Util.handleNewInstance(
at com.mysql.jdbc.ConnectionImpl.getInstance(
at com.mysql.jdbc.NonRegisteringDriver.connect(
at java.sql.DriverManager.getConnection(
at java.sql.DriverManager.getConnection(
at org.apache.sqoop.manager.SqlManager.makeConnection(
at org.apache.sqoop.manager.GenericJdbcManager.getConnection(
at org.apache.sqoop.manager.SqlManager.listTables(
at org.apache.sqoop.Sqoop.runSqoop(
at org.apache.sqoop.Sqoop.runTool(
at org.apache.sqoop.Sqoop.runTool(
at org.apache.sqoop.Sqoop.main(
Could not retrieve tables list from server
19/12/03 23:36:16 ERROR tool.ImportAllTablesTool: manager.listTables() returned null




That's a permission issue but root should by default have access to all the MySQL databases. Can you run this snippet

On the MySQL host 

# mysql -uroot -p'%root_password%'


Then grant root the desired privileges


mysql >GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '%root_password%' WITH GRANT OPTION;

Then retry  the import



"localhost" will not work here, because MySQL is accessed remotely from NodeManager hosts, not from the host you ran Sqoop command. So you need to use the FQDN of the MySQL host here.

Please also make sure that MySQL is reachable from ALL NodeManager hosts and can use the same username and password to login from those hosts.

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.