Can't able to connect retail_import database in spark


#1

Hi,

I have creates a table “narasimhasai_nbsxml” under “retail_import” DB and I am connecting that table in spark.

spark-shell --jars /usr/share/java/mysql-connector-java.jar

val sqlContext = new org.apache.spark.sql.SQLContext(sc)

val dataframe_mysql = sqlContext.read.format("jdbc")
.option("url", "jdbc:mysql://ms.itversity.com:3306/retail_import")
.option("driver", "com.mysql.jdbc.Driver").option("dbtable", "narasimhasai_nbsxml")
.option("user", "retail_user").option("password", "itversity").load()

am getting this exception

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user ‘retail_user’@’%’ to database ‘retail_import’

please advise.

Learn Spark 1.6.x or Spark 2.x on our state of the art big data labs

  • Click here for access to state of the art 13 node Hadoop and Spark Cluster


#2

Under ms.itversity.com host we do not have a database retail_import so in place of ms use nn01 try below code

val dataframe_mysql = sqlContext.read.format("jdbc").option("url", "jdbc:mysql://nn01.itversity.com:3306/retail_import").option("driver", "com.mysql.jdbc.Driver").option("dbtable", "narasimhasai_nbsxml").option("user","retail_dba").option("password", "itversity").load()

dataframe_mysql.show()