简体   繁体   English

如何通过ssh将php应用程序与远程mysql数据库连接

[英]how to connect php application with remote mysql database via ssh

I am developing a php application that needs to connect to mysql database in a remote host. 我正在开发一个PHP应用程序,该应用程序需要连接到远程主机中的mysql数据库。

I am using putty for SSH. 我正在将腻子用于SSH。 Mysql workbench can successfully connect to the remote server and browse the database and the putty also connects without a problem and allow me to work with command line. Mysql工作台可以成功连接到远程服务器并浏览数据库,而腻子也可以正常连接,并允许我使用命令行。

But the web application cannot connect. 但是Web应用程序无法连接。

It says access denied for user, the same username and password that I use to connect in putty command line . 它说拒绝用户访问,我使用腻子命令行连接用户名和密码。


I am using windows 7 and wamp sever 2.4 with Apache Version : 2.4.4 我正在使用Windows 7和wamp sever 2.4与Apache Version:2.4.4

PHP Version : 5.4.16 . PHP版本:5.4.16。


can anyone help me solve this issue? 谁能帮我解决这个问题?

I uncomment skip-networking in mysql.ini in wamp server. 我取消注释wamp服务器中mysql.ini中的跳过网络。 it is working now 现在正在工作

This has nothing to do with SSH username and password, You must use these parameters : 这与SSH用户名和密码无关 ,您必须使用以下参数:

$host = 'the host or IP that you are connecting with putty';
$username = 'mySQL username';
$password = 'mySQL passwrod';
//mySQL connection with above parameters .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM