Hello,
I set up a MySQL database on the server and I would like to establish a connection from my laptop. I copied the code from the instructions page and adapted it but it isn't able to query data or do anything. My code looks like this:
import sshtunnel
import mysql.connector
sshtunnel.SSH_TIMEOUT = 5.0
sshtunnel.TUNNEL_TIMEOUT = 5.0
with sshtunnel.SSHTunnelForwarder(
('ssh.pythonanywhere.com'),
ssh_username='balcse', ssh_password='***',
remote_bind_address=('balcse.mysql.pythonanywhere-services.com', 3306)
) as tunnel:
con = mysql.connector.connect(
user='balcse', password='***',
host='127.0.0.1', port=tunnel.local_bind_port,
database='balcse$dbname',
)
c=con.cursor()
print(c.execute("SELECT VERSION(), CURRENT_DATE;"))
con.close()
The ssh-tunnel is established but after that nothing happens. I get no error code or anything.
I had some troubles installing mysql (I have a Windows 10 machine) so I think the problem lies in that part but I also tried to connect to the database via pymysql, there I get the error 2003 "Can't connect to MySQL server on 'localhost'".
Many thanks for your help in advance :)
Update: Also tried to connect via MySQL Workbench, there I get the error "Failed to Connect to MYSQL at balcse.mysql.pythonanywhere-services.com:3306 through SSH tunnel a balcse@ssh.pythonanywhere.com with user balcse Access denied for user 'balcse'@'10.0.0.78' (using password: YES)"