我正在尝试从MySQL导入一些数据通过sqoop来配置单元。当sqoop和mysql db都在同一主机上时,它将起作用,否则它将失败。这是我正在执行的查询。

[user@xyz ~]$ sqoop import --connect "jdbc:mysql://abc.something.com/test" --username user --password pass --table dataSql --hive-import --hive-table test.dataHive --target-dir /tmp/sqoop$RANDOM

请注意,我目前在主机xyz上,并且我正在尝试连接到主机abc上的mysql数据库。以下是我看到的错误。
ERROR: org.apache.sqoop.manager.SqlManager - Error executing statement: java.sql.SQLException: Access denied for user 'user'@'xyz.something.com' (using password: YES)
.
.
.
ERROR: org.apache.sqoop.manager.CatalogQueryManager - Failed to list columns java.sql.SQLException: Access denied for user 'user'@'xyz.something.com' (using password: YES)
.
.
.

等等。我的问题是,为什么我的机器将其主机名附加到用户名('user'@'xyz.something.com')?我该如何解决?

最佳答案

当sqoop和mysql位于同一主机上时,最有可能的ip源是localhost,在远程主机上,这不再是正确的,并且您将拒绝访问。

登录mysql并执行以下查询:

mysql> select user, host from user;
+------------+---------------------+
| user       | host                |
+------------+---------------------+
| amon       | %                   |
| cm         | %                   |
| hive       | %                   |
| hue        | %                   |
| nav        | %                   |
| navms      | %                   |
| oozie      | %                   |
| retail_dba | %                   |
| rman       | %                   |
| sentry     | %                   |
| root       | 127.0.0.1           |
| root       | localhost           |
| root       | quickstart.cloudera |
+------------+---------------------+

检查您的用户名user是否在此表中,并将%(任何)作为主机名或xyz.something.com。如果您的用户不在此表中,则需要添加它:
mysql> create user 'test'@'%' identified by 'password';
mysql> grant select privileges on *.* to 'test'@'%';
mysql> flush privileges;

关于mysql - 从MySQL将sqoop导入到配置单元,更改用户名(拒绝用户访问),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32082686/

10-16 05:33
查看更多