Я пытаюсь подключиться к базе данных mysql на удаленном сервере через ssh туннель.
Когда соединение с сервером установлено, мой скрипт завершается с ошибкой 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
, то все в порядке, ошибок не обнаружено, и mysql cli открывается.
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