python 使用mysql,报如下错误
Python 3.6.8 (v3.6.8:3c6b436a57, Dec 24 2018, 02:04:31)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mysql
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mysql'
解法
pip3 install mysql-connector-python-rf
Mac 安装符合python版本的pip
直接easyinstall pip 装的pip和python版本有可能不匹配
解法
curl https://bootstrap.pypa.io/pip/get-pip.py -o get-pip.py
python3 get-pip.py
Authentication plugin ‘caching_sha2_password’ is not supported
db = db_util.open_db(args, create_not_exist_db=True)
File "../../../utils/db_util.py", line 23, in open_db
db = Database(args.host, args.port, args.user, args.database, pwd, create_not_exist_db)
File "../../../utils/db_util.py", line 47, in __init__
create_db(host, port, user, database, pwd)
File "../../../utils/db_util.py", line 32, in create_db
password=pwd
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mysql/connector/__init__.py", line 179, in connect
return MySQLConnection(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mysql/connector/connection.py", line 95, in __init__
self.connect(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mysql/connector/abstracts.py", line 716, in connect
self._open_connection()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mysql/connector/connection.py", line 210, in _open_connection
self._ssl)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mysql/connector/connection.py", line 142, in _do_auth
auth_plugin=self._auth_plugin)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mysql/connector/protocol.py", line 102, in make_auth
auth_data, ssl_enabled)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mysql/connector/protocol.py", line 58, in _auth_response
auth = get_auth_plugin(auth_plugin)(
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mysql/connector/authentication.py", line 191, in get_auth_plugin
"Authentication plugin '{0}' is not supported".format(plugin_name))
mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported
解法
pip install mysql-connector-python