ピックアップ
PythonでMySQL接続時に「mysql.connector.errors.InterfaceError: sha256_password requires SSL」
MySQLのバージョン確認
mysqlのコマンドラインで確認
mysql -V実行結果
$  mysql -V
mysql  Ver 8.0.27-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))実行内容とエラー
MySQLでアクセスを実施
import mysql.connector
cnx = mysql.connector.connect(user='user', password='password',
                                host='123.123.123.123')実行時のエラー
$ python3 test.py
 :
raise errors.InterfaceError("{name} requires SSL".format(
mysql.connector.errors.InterfaceError: sha256_password requires SSLエラー内容と対応
エラー内容としては、
raise errors.InterfaceError("{name} requires SSL".format(
mysql.connector.errors.InterfaceError: sha256_password requires SSLというエラーログがあり、
sha256のパスワードでSSLが必要とのこと。
この点を公式の内容で確認してみたら、
実際に記述がありました。
公式サイトのページ
MySQLの「7.1 Connector/Python Connection Arguments」
公式サイトの一部抜粋

公式サイトの文章をメモ
Connector/Python supports authentication plugins available as of MySQL 5.6. 
This includes mysql_clear_password and sha256_password, 
both of which require an SSL connection. 
The sha256_password plugin does not work over a non-SSL connection 
because Connector/Python does not support RSA encryption.The connect() method supports an auth_plugin argument 
that can be used to force use of a particular plugin. 
For example, 
if the server is configured to use sha256_password by default 
and you want to connect to an account that authenticates using mysql_native_password, 
either connect using SSL or specify auth_plugin='mysql_native_password'.このようになっているので、
auth_plugin='mysql_native_password'をオプションにつけてやることで、
うまく実行ができるようになる。
おすすめ書籍
コメント一覧
コメントはまだありません。



 
           
           
           
           
           
           
           
           
          
 
           
           
      
コメントを残す