0

I tried to import data through Sqoop using the following command.

sqoop import -connect jdbc:mysql://localhost/test_sqoop --username root --table test

but I got the connection refuse error.

And I found out I can't connect to mysql and got this error:

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

And I also found out if I don't execute start-dfs.sh,mysql.sock exists in /var/lib/mysql/mysql.sock.

mysql

After I executed start-dfs.sh,mysql.sock would be gone and I can't connect to mysql.

start-dfs.sh

Below is /etc/my.cnf configuration.

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

J.Chen
  • 1
  • 2
  • Could you please share the content of your `/etc/my.cnf` file? There should be a section called [client] with something like this `socket=/var/lib/mysql/mysql.sock`. Can you execute this command? `mysql.server start` – Jaime Caffarel Jul 17 '16 at 15:18
  • My /etc/cnf has configured socket=/var/lib/mysql/mysql.sock but not in the section [client] but [mysqld].And when I execute the command mysql.server start,it shows 'command not found' error. – J.Chen Jul 19 '16 at 14:00
  • I think that your MySQL is not running, have you tried to do some of these answers to the same problem? http://stackoverflow.com/questions/4448467/cant-connect-to-local-mysql-server-through-socket-var-lib-mysql-mysql-sock Maybe it's just a matter of permissions or something very simple to fix. – Jaime Caffarel Jul 19 '16 at 19:01

1 Answers1

0
  • jdbc string should be: jdbc:mysql://localhost:3306/test_sqoop, best practice is to use server name intesad of localhost or 127.0.0.1. you can get the server name from this command hostname -f. so jdbc string should be jdbc:mysql://servername:3306/test_sqoop - replace the server name by out put of hostname -f command.
  • you need -P or --password or --connection-param-file to pass the password to the sqoop command. sqoop doesn't read from .my.cnf file. - see usage here
Ronak Patel
  • 3,819
  • 1
  • 16
  • 29