首页 文章

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

提问于
浏览
18

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

My settings are:

数据库选项卡:

  • 主持人:127.0.0.1
  • 港口:3306
  • 用户:root
  • 密码:root_passsword

SSH / SSL选项卡:

  • 代理主机:192.168.56.102
  • 港口:22
  • 代理用户:vagrant
  • 代理密码:流浪汉

有人能帮我吗?谢谢

2 回答

  • 8

    在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
    
  • 26

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

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

    那是:

    • 在PhpStorm中单击视图 - >工具窗口 - >数据库

    • 单击数据库侧栏,单击新建 - >数据源 - > MySQL将出现配置窗口

    • 打开终端 .

    • 转到您的项目: cd ~/path/to/your/project

    • 从终端运行 vagrant ssh-config 命令

    • 在您正在创建的连接的PhpStorm配置窗口中,转到SSH / SSL选项卡

    • 选择"Use SSH tunnel"并从终端输入数据 . 验证类型应为"Key pair (Open SSH)" .

    • 复制"Host name"至"Proxy host","Port"至"port","User"至"Proxy user"和"Identity file"至"Private key file"

    • 在"General"选项卡中,您应该像在虚拟机上一样输入数据库连接数据(即从项目数据库设置中复制) .

    • 测试你的连接 .

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

相关问题