Can't able to connect retail_import database in spark



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 ="jdbc")
.option("url", "jdbc:mysql://")
.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


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

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