Python MySQLConnection错误:拒绝用户访问';rnd管理员'@';本地主机';(使用密码:是)
我正在尝试通过ssh隧道连接到远程服务器上的mysql数据库。Python MySQLConnection错误:拒绝用户访问';rnd管理员'@';本地主机';(使用密码:是),python,mysql,ssh,terminal,mariadb,Python,Mysql,Ssh,Terminal,Mariadb,我正在尝试通过ssh隧道连接到远程服务器上的mysql数据库。 与服务器建立连接时,我的脚本失败,出现mysql错误: py.warnings - WARNING - /home/artur/Exposit/Projects/dataset-collector/venv/lib/python3.6/site-packages/paramiko/kex_ecdh_nist.py:39: CryptographyDeprecationWarning: encode_point has been de
与服务器建立连接时,我的脚本失败,出现mysql错误:
py.warnings - WARNING - /home/artur/Exposit/Projects/dataset-collector/venv/lib/python3.6/site-packages/paramiko/kex_ecdh_nist.py:39: CryptographyDeprecationWarning: encode_point has been deprecated on EllipticCurvePublicNumbers and will be removed in a future version. Please use EllipticCurvePublicKey.public_bytes to obtain both compressed and uncompressed point encoding.
m.add_string(self.Q_C.public_numbers().encode_point())
py.warnings - WARNING - /home/artur/Exposit/Projects/dataset-collector/venv/lib/python3.6/site-packages/paramiko/kex_ecdh_nist.py:96: CryptographyDeprecationWarning: Support for unsafe construction of public numbers from encoded data will be removed in a future version. Please use EllipticCurvePublicKey.from_encoded_point
self.curve, Q_S_bytes
py.warnings - WARNING - /home/artur/Exposit/Projects/dataset-collector/venv/lib/python3.6/site-packages/paramiko/kex_ecdh_nist.py:111: CryptographyDeprecationWarning: encode_point has been deprecated on EllipticCurvePublicNumbers and will be removed in a future version. Please use EllipticCurvePublicKey.public_bytes to obtain both compressed and uncompressed point encoding.
hm.add_string(self.Q_C.public_numbers().encode_point())
root - ERROR - 1045 (28000): Access denied for user 'rnd-admin'@'localhost' (using password: YES)
Access denied for user 'rnd-admin'@'localhost' (using password: YES).
注意:
当我使用mysql-u rnd admin-p
从具有相同信用的终端连接到数据库时,一切正常,没有检测到错误,并且mysqlcli被打开
with SSHTunnelForwarder(
('myhost', 22),
ssh_username="root",
ssh_password="passwd",
remote_bind_address=('127.0.0.1', 3306)) as tunnel:
if tunnel.is_active:
db_config = read_db_config()
conn = MySQLConnection(**db_config)
cursor = conn.cursor()
cursor.execute(query)
result = cursor.fetchall()
conn.commit()
cursor.close()
conn.close()
config.ini
[mysql]
host=127.0.0.1
port=3306
database=db-name
user=rnd-admin
password=pass
通过从config.ini中删除
3306
mysql默认端口并手动将port=tunnel.local\u bind\u port
输入到MySQLConnection构造函数中,修复了此问题
conn = MySQLConnection(**db_config, port=tunnel.local_bind_port)
通过从config.ini中删除
3306
mysql默认端口并手动将port=tunnel.local\u bind\u port
输入到MySQLConnection构造函数中,修复了此问题
conn = MySQLConnection(**db_config, port=tunnel.local_bind_port)
我正要说你根本没有使用SSHTunnelForwarder的端口,但你找到了答案。:)我还建议确保
主机总是127.0.0.1
(因为这是隧道绑定的地方):db_config=read_db_config();db_config.update(host='127.0.0.1',port=tunnel.local_bind_port)
我想说您根本没有使用SSHTunnelForwarder的端口,但您已经解决了。:)我还建议确保主机总是127.0.0.1
(因为这是隧道绑定的地方):db_config=read_db_config();db\u config.update(host='127.0.0.1',port=tunnel.local\u bind\u port)