1.启动spark-shell

./spark-shell --master local[2] --jars /usr/local/jar/mysql-connector-java-5.1.47.jar

maste:制定运行模式
local[2]:local本地模式  [2]:2个CUP来运行spark-shell
--jars: 制定jar包   ,用逗号隔开可以制定多个jar包

2.启动spark-sql

./spark-sql --master local[2] --jars /usr/local/jar/mysql-connector-java-5.1.47.jar --driver-class-path /usr/local/jar/mysql-connector-java-5.1.47.jar