我尝试使用spark连接到mysql db,使用以下命令:
os.environ['LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN'] = '1'
df = spark.read.jdbc("jdbc:mysql://<host>:<port>/<db_name>", "<table>", properties={"user": "spark", "password": password})
我得到了这个错误:
Access denied for user 'spark'@'<ip>' (using password: NO)
Current charset is US-ASCII. If password has been set using other charset, consider using option 'passwordCharacterEncoding'
所以我试着写了这段python代码,一切都没有问题:
os.environ['LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN'] = '1'
mysql.connector.connect(user=user, password=password, host=host, database=db_name,
raise_on_warnings=True)
我尝试将authenticationPlugins: mysql_clear_password
添加到属性中,但得到相同的错误
1条答案
按热度按时间7nbnzgx91#
试试这个:
参考:how-to-integrate-apache-spark-with-mysql-for-reading-database-tables-as-a-spark