ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

Django通过ssh跳转连接mysql,setting.py设置

2021-11-25 18:00:07  阅读:21  来源: 互联网

标签:127.0 0.1 bind address Django setting ssh 跳转 server


server = SSHTunnelForwarder(
ssh_address_or_host='33.103.212.66', # 跳板机B地址
ssh_port=22, # 跳板机B端口
ssh_username='root',
ssh_password='crmQ@cI@voBe%k!fNdffdafdfsdf',
# local_bind_address=('127.0.0.1', 22), # 这里必须填127.0.0.1
remote_bind_address=('10.111.12.123', 3306) # 目标机器A地址,端口
)
server.start()

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': '127.0.0.1',
'PORT': server.local_bind_port,
'NAME': 'db_test',
'USER': 'jusr8pr5kbrj',
'PASSWORD': 'TbH9&UJR8LZh7oZ7'
''
''
'',
'OPTIONS': {
'sql_mode': 'traditional',
}
}
}

标签:127.0,0.1,bind,address,Django,setting,ssh,跳转,server
来源: https://www.cnblogs.com/yuminhu/p/15603929.html

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有