sqlalchemy 连接到 VPS 数据库 [英] sqlalchemy connect to VPS database

查看:45
本文介绍了sqlalchemy 连接到 VPS 数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我的 PC 连接到 VPS mysql 数据库.我使用的是sqlalchemy框架,但是我需要在连接之前建立SSH隧道.

I am trying to connect to VPS mysql database from my PC. I use sqlalchemy framework, but I need establish SSH tunnel before connection.

通常的方式,当 Web 应用程序在 VPS 上运行时:

Usual way, when web app run on VPS:

create_engine('mysql://user:pswd@localhost/dbname')

如何从另一台 PC 连接到此数据库.假设有连接凭证:IP、用户名、密码

How can I connect to this database from another PC. Assume there are connections credentials: IP, username, password

推荐答案

您的 MySQL 服务器仅侦听本地连接.让它侦听外部连接:

Your MySQL server is listening to local connections only. To make it listen to outside connections:

  1. 编辑/etc/mysl/my.cnf文件
  2. 注释掉bind-address = 127.0.0.1
  3. 重启mysqld

这篇关于sqlalchemy 连接到 VPS 数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆