2015-06-13 39 views
14

我无法使用PhpStorm在流浪机中创建到MySQL数据库的连接。连接到PhpStorm的流浪机上的MySQL数据库

我的设置是:

DATABASE标签:
- 主机:127.0.0.1
- 端口:3306
- 用户:根
- 密码:root_passsword

SSH/SSL选项卡:
- 代理主机:192.168.56.102
- Por T:22
- 代理用户:流浪汉
- 代理密码:流浪汉

有人能帮助我吗?谢谢

+1

从[本教程为流浪汉](https://confluence.jetbrains.com/display/PhpStorm/Working+with+Advanced+Vagrant+features+in+PhpStorm#WorkingwithAdvancedVagrantfeaturesinPhpStorm-1.2.Provideconnectioninformation) - 请尝试'您的SSH/SSL选项卡中的127.0.0.1'和​​'2222'。 – LazyOne

+0

这篇文章对我很有帮助(特别是SSH部分,没有意识到我必须这样做)。 – Jimbo

+0

谢谢@LazyOne!那个链接对我来说至关重要! – Ryan

回答

19

在SSH/SSL选项卡中,选择Auth type Key pair,然后将路径复制到IdentityFile中的私钥文件define。例如C:/virtualM/deb56/puphpet/files/dot/ssh/id_rsa

$vagrant up 
$vagrant ssh-config 
Host local 
    HostName 127.0.0.1 
    User vagrant 
    Port 2222 
    UserKnownHostsFile /dev/null 
    StrictHostKeyChecking no 
    PasswordAuthentication no 
    IdentityFile "C:/virtualM/deb56/puphpet/files/dot/ssh/id_rsa" 
    IdentityFile "C:/Users/User/.vagrant.d/insecure_private_key" 
    IdentitiesOnly yes 
    LogLevel FATAL 
+4

谢谢,'vagrant ssh-config'命令帮助我找到在phpStorm中使用哪个键。 – mfink

3

下面是关于这个问题的一个非常好的文章:

https://www.theodo.fr/blog/2017/03/how-to-manipulate-the-mysql-database-of-your-vagrant-from-phpstorm/

即:

  1. 在PhpStorm点击查看 - >工具窗口 - >数据库
  2. 点击数据库边栏,点击新建 - >数据源 - > MySQL 将出现配置窗口
  3. 打开您的终端。
  4. 转到您的项目:vagrant ssh-config命令从终端
  5. 在PhpStorm配置窗口cd ~/path/to/your/project
  6. 运行正在创建去SSH/SSL选项卡
  7. 选择“使用SSH隧道”,并从输入数据连接终奌站。身份验证类型应该是“密钥对(Open SSH)”。
  8. 将“主机名”复制到“代理主机”,“端口到端口”,“用户”到“代理用户”和“标识文件”到“私钥文件”
  9. 在“常规”您在虚拟机上的数据库连接数据(即从您的项目数据库设置复制)。
  10. 测试您的连接。

或者只是访问我在顶部发布的URL。