title: What am I doing wrong? Trying to use PySpark to connect to mySql database but I keep receiving load error
body: <p>I am trying to use PySpark to connect to a mySql database but am receiving an error. I don't know what the config setup means in the SparkSession code below - this is my first attempt at using spark so I have been following tutorials like here <a href="https://towardsdatascience.com/create-your-first-etl-pipeline-in-apache-spark-and-python-ec3d12e2c169" rel="nofollow noreferrer">https://towardsdatascience.com/create-your-first-etl-pipeline-in-apache-spark-and-python-ec3d12e2c169</a>. </p>
  
  <p>The mySql database I am trying to connect to is accessible through Sequel Pro, and I have successfully connected to it using my credentials that I input into the code here (mytable is not the literal table, likewise mydb and mypass are different strings).</p>
  
  <pre><code>scSpark = SparkSession \
          .builder \
          .appName("reading csv") \
          .config("spark.driver.extraClassPath", "/usr/local/spark/jars/mysql-connector-java-8.0.16.jar") \
          .getOrCreate()
  
  from pyspark.sql import SQLContext
  mySqlContext = SQLContext(scSpark)
  </code></pre>
  
  <p>And then I run the code below and receive the error...</p>
  
  <pre><code>    url="jdbc:mysql://localhost:3306/mydb",
      driver = "com.mysql.jdbc.Driver",
      dbtable = "mytable",
      user="guest",
      password="mypass").load()
  </code></pre>
  
  <p>Here is the error:</p>
  
  <pre><code>&lt;ipython-input-27-811547d9be98&gt; in &lt;module&gt;()
        4     dbtable = "mytable",
        5     user="guest",
  ----&gt; 6     password="mypass").load()
  
  /anaconda3/lib/python3.6/site-packages/pyspark/sql/readwriter.py in load(self, path, format, schema, **options)
      170             return self._df(self._jreader.load(self._spark._sc._jvm.PythonUtils.toSeq(path)))
      171         else:
  --&gt; 172             return self._df(self._jreader.load())
      173 
      174     @since(1.4)
  
  /anaconda3/lib/python3.6/site-packages/py4j/java_gateway.py in __call__(self, *args)
     1255         answer = self.gateway_client.send_command(command)
     1256         return_value = get_return_value(
  -&gt; 1257             answer, self.gateway_client, self.target_id, self.name)
     1258 
     1259         for temp_arg in temp_args:
  
  /anaconda3/lib/python3.6/site-packages/pyspark/sql/utils.py in deco(*a, **kw)
       61     def deco(*a, **kw):
       62         try:
  ---&gt; 63             return f(*a, **kw)
       64         except py4j.protocol.Py4JJavaError as e:
       65             s = e.java_exception.toString()
  
  /anaconda3/lib/python3.6/site-packages/py4j/protocol.py in get_return_value(answer, gateway_client, target_id, name)
      326                 raise Py4JJavaError(
      327                     "An error occurred while calling {0}{1}{2}.\n".
  --&gt; 328                     format(target_id, ".", name), value)
      329             else:
      330                 raise Py4JError(
  
  Py4JJavaError: An error occurred while calling o340.load.
  : java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
      at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
      at org.apache.spark.sql.execution.datasources.jdbc.DriverRegistry$.register(DriverRegistry.scala:45)
      at org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions$$anonfun$5.apply(JDBCOptions.scala:99)
      at org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions$$anonfun$5.apply(JDBCOptions.scala:99)
      at scala.Option.foreach(Option.scala:257)
      at org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions.&lt;init&gt;(JDBCOptions.scala:99)
      at org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions.&lt;init&gt;(JDBCOptions.scala:35)
      at org.apache.spark.sql.execution.datasources.jdbc.JdbcRelationProvider.createRelation(JdbcRelationProvider.scala:32)
      at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:318)
      at org.apache.spark.sql.DataFrameReader.loadV1Source(DataFrameReader.scala:223)
      at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:211)
      at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:167)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
      at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
      at py4j.Gateway.invoke(Gateway.java:282)
      at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
      at py4j.commands.CallCommand.execute(CallCommand.java:79)
      at py4j.GatewayConnection.run(GatewayConnection.java:238)
      at java.lang.Thread.run(Thread.java:748)
  </code></pre>