在PhpStorm中连接到vagrant机器上的MySQL数据库

gna*_*ell 20 mysql connection phpstorm vagrant

我无法使用PhpStorm在流浪汉机器中创建与MySQL数据库的连接.

我的设置是:

数据库选项卡:
- 主机:127.0.0.1
- 端口:3306
- 用户:root
- 密码:root_passsword

SSH/SSL选项卡:
- 代理主机:192.168.56.102
- 端口:22
- 代理用户:vagrant
- 代理密码:vagrant

有人能帮我吗?谢谢

ous*_*aka 27

在SSH/SSL选项卡中,选择Auth type Key pair,然后将路径复制到私钥文件中定义IdentityFile.例如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
Run Code Online (Sandbox Code Playgroud)

  • 谢谢,`vagrant ssh-config`命令帮助我找到在phpStorm中使用的密钥. (6认同)

Mil*_*anG 12

这是一篇关于这个主题的非常好的文章:

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

那是:

  1. 在PhpStorm中单击View - > Tool Windows - > Database
  2. 单击Database侧栏,单击new - > Datasource - > MySQL将出现配置窗口
  3. 打开你的终端.
  4. 转到您的项目: cd ~/path/to/your/project
  5. vagrant ssh-config从终端运行命令
  6. 在用于连接的PhpStorm配置窗口中,您将创建转到SSH/SSL选项卡
  7. 选择"使用SSH隧道"并从终端输入数据.Auth类型应为"密钥对(Open SSH)".
  8. 将"主机名"复制到"代理主机",将"端口"复制到"端口",将"用户"复制到"代理用户",将"身份文件"复制到"私钥文件"
  9. 在"常规"选项卡中,您应该像在虚拟机上一样输入数据库连接数据(即从项目数据库设置中复制).
  10. 测试你的连接.

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