Support Questions
Find answers, ask questions, and share your expertise

Sqoop connection string for MySql

Sqoop connection string for MySql




I want to know that how can we  find the connection string to import the data from Mysql using sqoop on cluster.


Like on local cloudera VM, usually we use "jdbc:mysql://quickstart.cloudera:3306/<database-name>

 where quicstart.cloudera is hostname.

If I type the shell command   $ hostname     it retrieve the quickstart.cloudera.

As everything is on one machine, so we use this hostname,


But on cluster suppose we have four worker nodes, one master node,  we have given username and password for Mysql,  How we can check the hostname for connection string.  Will it be same like if i run the shell command $ hostname , and i have to use the that result of this command as hostname.   and moreover on local VM i even don't need port no. so on cluster how can we check the port no. also??


I am very badly stuck over here.

so really need a favor.






Re: Sqoop connection string for MySql

Master Guru
Your MySQL JDBC connection string comprises of a hostname and port. These two values must match the host that is running your MySQL server, and the port its client services are provided on.

These do not change regardless of using a pseudo-distributed cluster or a fully-distributed one. Nor do these depend on the cluster's configuration - MySQL is an independent entity, and to ask Sqoop to connect to it requires just the right host and port of where it lies (and is accessible via).

P.s. Not specifying a port number causes it to fallback to defaults, which is 3306. If you are certain you are running default MySQL ports, then you may skip specifying ports, to use defaults. In my opinion though, explicit is better than implicit, wherever possible.

Re: Sqoop connection string for MySql


Hi Harsh,

Thanks for response. But my big confusion is that how can I came to know that MySQL is installed on which hostname. How can I get that hostname, if I don't know, on local machine or on pseduodistributed mode, actually there is one host , so I can get the hostname , easily by running the command  $hostname


But on actual cluster it will not work. If  I am right??

I have found the one solution , pleasae validate it if it will give me the correct hostname on which MySQL is installed.

1. login mysql as root

$ mysql -u root -p


2. mysql> use mysql;

3. mysql> select host, user from user;


| host | user |
| % | amon |
| % | cm |
| % | hive |
| % | hue |
| % | nav |
| % | navms |
| % | oozie |
| % | retail_db |
| % | retail_dba |
| % | rman |
| % | sentry |
| | root |
| localhost | root |
| quickstart.cloudera | root |
14 rows in set (0.05 sec)



it will give me the hostname of root.

and it can be used in connection string to make connection.



Re: Sqoop connection string for MySql

New Contributor

Hi Harsh,


I also have same doubt how to get hostname for connection string when I'm not aware on which machine mysql is running in a cluster enviornment.



Re: Sqoop connection string for MySql


@Manish22   all business will have some kind of mapping doc / excel  to let you know where the mysql is ruining like which host and its credentials ,database , tables etc . if you just want to see the hostaname  all you can do is fire $HOSTNAME in the terminal . that will return the hostname are go to /etc/hostname or /etc/syconfig/network . Hope this helps