简体   繁体   English

无法从远程计算机上的mysql工作台连接到phpmyadmin或数据库

[英]Unable to connect to phpmyadmin or to database from mysql workbench on remote computer

I've looked around and found many articles on how to get this to work but nothing I've tried has been successful. 我环顾四周,发现了许多有关如何使其工作的文章,但是我尝试过的任何事都没有成功。

I have a Windows 8 (64-bit) vm on a local network and am trying to connect to it to edit the Database. 我在本地网络上有Windows 8(64位)虚拟机,并试图连接到该虚拟机以编辑数据库。 Through Microsoft Remote Desktop I am able to connect to phpmyadmin without a problem, but can't connect to it via browser on the computer that is running MRD. 通过Microsoft远程桌面,我可以毫无问题地连接到phpmyadmin,但是无法通过运行MRD的计算机上的浏览器连接到它。 I've tried adding a second user, and set the host column to % for both the root and secondary users. 我尝试添加第二个用户,并将root用户和辅助用户的host列设置为%。 I've also created a password for root. 我还为root创建了密码。

I have tried a lot of the different Allow/Deny directives in the .conf files in Wamp's Alias folder. 我在Wamp的Alias文件夹的.conf文件中尝试了很多不同的Allow / Deny指令。 The examples I've seen are a bit different though, as theirs just show the directives, while I have this in the confs: 我所看到的示例有些不同,因为它们仅显示了指令,而我在confs中有此指令:

  <IfDefine APACHE24>
    Require local
  </IfDefine>
  <IfDefine !APACHE24>
    Order Allow,Deny
    Allow from all
    </IfDefine>

Been pounding my head against the wall for a couple of weeks now. 现在已经将我的头撞在墙上几周了。 While I can access the DB via Remote Desktop, I am not the only user of the VM and it's more efficient if I can access it via my computer, and even better if I can use Workbench. 虽然可以通过远程桌面访问数据库,但我不是VM的唯一用户,如果可以通过计算机访问数据库,效率会更高,如果可以使用Workbench,效率会更高。

Forgot to mention: While I need the above for myself, it will also need to be available for any users of the network, even via VPN. 忘了提及:虽然我自己需要以上这些,但它也需要对网络的任何用户都可用,即使通过VPN也是如此。

You can set up an SSH tunnel to forward your localhost:13306 to remote:3306 using 您可以设置SSH隧道以使用以下方式将localhost:13306转发到remote:3306

ssh -L13306:dbhost:3306 user@remotehost

This will listen on port 13306 on your localhost, forward connections over the ssh tunnel to remotehost , where they are then forwarded to dbhost port 3306 . 这将监听本地主机上的端口13306 ,通过ssh隧道将连接转发到remotehost ,然后将其转发到dbhost端口3306 If that database runs on the remote machine itself, use localhost for dbhost , which will be simply 127.0.0.1 as seen from the remote machine: 如果该数据库在远程计算机本身上运行,则将localhost用于dbhost ,从远程计算机上可以看到它只是127.0.0.1

ssh -L13306:localhost:3306

If you're on windows, you can set up SSH tunnels with Putty. 如果您在Windows上,则可以使用Putty设置SSH隧道。

Once you've logged in, you can connect to the remote database by connecting to localhost:13306 on your machine. 登录后,可以通过连接到计算机上的localhost:13306来连接到远程数据库。

After some desperation digging I finally found the problem. 经过一番无奈的挖掘,我终于找到了问题所在。 I was able to change a couple of settings in phpmyadmin's config.php from localhost to the web server URL. 我能够将phpmyadmin的config.php中的几个设置从localhost更改为Web服务器URL。 I had done this once before so not sure why it didn't work the first time. 我以前做过一次,所以不确定为什么第一次不起作用。 Might have been that I hadn't changed host to % in the db. 可能是因为我没有在数据库中将主机更改为%。

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

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