We should connect to mysql in the following way:
- Connect using ssh to global server
- Connect from global to local server using ssh
- Connect to mysql using command "mysql –p" or "mysql --local-infile=1 -p"
Is there a way to do all this stuff without putty or similar tools, but using python script. I find how to connect to local server using paramiko:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname=host, username=user,port = password, password=secret, key_filename=path)
vmtransport = ssh.get_transport()
vmchannel = vmtransport.open_channel("direct-tcpip", dest_addr, local_addr)
jhost = paramiko.SSHClient()
jhost.set_missing_host_key_policy(paramiko.AutoAddPolicy())
jhost.connect(hostname=dest_addr[0], username=user, password=secret, sock=vmchannel,
key_filename = second_file_path)
after i connect to local how can i connect to mysql from it, using only password or i can only connect directly to mysql, using tonnel?