weixin_39948442
2021-01-10 06:26 阅读 4

Connect using MySql Workbench on Ubuntu

Hi, I'm trying to connect to mysql using Workbench from my Ubuntu (host) but I keep getting this error:

Failed to Connect to MySQL at 127.0.0.1:3306 through SSH tunnel at 127.0.0.1:2222 with user root Lost connection to MySQL server at 'reading initial communication packet', system error: 0

Here is my config.yaml

 yaml
vagrantfile-local:
    vm:
        box: puphpet/ubuntu1404-x64
        box_url: puphpet/ubuntu1404-x64
        hostname: ''
        memory: '2048'
        cpus: '1'
        chosen_provider: virtualbox
        network:
            private_network: 192.168.10.10
            forwarded_port:
                Tj5356X3Sx9q:
                    host: '6164'
                    guest: '22'
                OJRi5sWB5DwG:
                    host: '8080'
                    guest: '80'
                TI0o1Y56Es1c:
                    host: '33060'
                    guest: '3306'
                GBXEniAHAZ34:
                    host: '54320'
                    guest: '5432'
        post_up_message: ''
        provider:
            virtualbox:
                modifyvm:
                    natdnshostresolver1: on
            vmware:
                numvcpus: 1
            parallels:
                cpus: 1
        provision:
            puppet:
                manifests_path: puphpet/puppet
                manifest_file: site.pp
                module_path: puphpet/puppet/modules
                options:
                    - '--verbose'
                    - '--hiera_config /vagrant/puphpet/puppet/hiera.yaml'
                    - '--parser future'
        synced_folder:
            HHGiqqqsQw87:
                owner: www-data
                group: www-data
                source: ~/Code
                target: /home/vagrant/Code
                sync_type: default
                rsync:
                    args:
                        - '--verbose'
                        - '--archive'
                        - '-z'
                    exclude:
                        - .vagrant/
                    auto: 'false'
        usable_port_range:
            start: 10200
            stop: 10500
    ssh:
        host: null
        port: null
        private_key_path: null
        username: vagrant
        guest_port: null
        keep_alive: true
        forward_agent: false
        forward_x11: false
        shell: 'bash -l'
    vagrant:
        host: detect
server:
    install: '1'
    packages:
        - vim
        - vim-common
        - build-essential
        - memcached
        - python-pip
        - python2.7-dev
firewall:
    install: '1'
    rules: 
        rMco8Q6yzyFV:
            port: '3306'
            priority: '100'
            proto: tcp
            action: accept
apache:
    install: 0
    settings:
        user: www-data
        group: www-data
        default_vhost: true
        manage_user: false
        manage_group: false
        sendfile: 0
    modules:
        - rewrite
    vhosts:
        KRhvik9Z4vUQ:
            servername: awesome.dev
            serveraliases:
                - www.awesome.dev
            docroot: /var/www/awesome
            port: '80'
            setenv:
                - 'APP_ENV dev'
            override:
                - All
            options:
                - Indexes
                - FollowSymLinks
                - MultiViews
            engine: php
            custom_fragment: ''
            ssl_cert: ''
            ssl_key: ''
            ssl_chain: ''
            ssl_certs_dir: ''
    mod_pagespeed: 0
nginx:
    install: '1'
    settings:
        default_vhost: 1
        proxy_buffer_size: 128k
        proxy_buffers: '4 256k'
    upstreams: {  }
    vhosts:
        TPw4I5JjYVOn:
            proxy: ''
            server_name: cloverbox.dev
            server_aliases:
                - cloverbox.dev
                - www.cloverbox.dev
            www_root: /home/vagrant/Code/cloverbox/public
            listen_port: '80'
            location: \.php$
            index_files:
                - index.html
                - index.htm
                - index.php
            envvars:
                - 'ENV dev'
            engine: php
            client_max_body_size: 1m
            ssl_cert: ''
            ssl_key: ''
php:
    install: '1'
    version: '56'
    composer: '1'
    composer_home: ''
    modules:
        php:
            - cli
            - intl
            - mcrypt
            - mysql
            - common
            - curl
            - fpm
            - mbstring
            - memcache
        pear: {  }
        pecl:
            - pecl_http
            - memcache
    ini:
        display_errors: On
        error_reporting: '-1'
        session.save_path: /var/lib/php/session
        default_charset: 'utf-8'
        post_max_size: 99
        upload_max_filesize: 98
    timezone: America/Sao_Paulo
    mod_php: 0
hhvm:
    install: '0'
    nightly: 0
    composer: '1'
    composer_home: ''
    settings:
        host: 127.0.0.1
        port: '9000'
    ini:
        display_errors: On
        error_reporting: '-1'
    timezone: null
xdebug:
    install: '1'
    settings:
        xdebug.default_enable: '1'
        xdebug.remote_autostart: '0'
        xdebug.remote_connect_back: '1'
        xdebug.remote_enable: '1'
        xdebug.remote_handler: dbgp
        xdebug.remote_port: '9000'
        xdebug.idekey: 'vagrant'
xhprof:
    install: '0'
wpcli:
    install: '0'
    version: v0.17.1
drush:
    install: '0'
    version: 6.3.0
ruby:
    install: '1'
    versions:
        Wg7JKlcWS0og:
            version: ''
nodejs:
    install: '0'
    npm_packages:
        - bower
        - 'git://github.com/kimus/bower-installer'
        - gulp
python:
    install: '1'
    packages: {  }
    versions:
        EKKT4csNpbxM:
            version: ''
mysql:
    install: '1'
    override_options: {  }
    root_password: secret
    adminer: 0
    databases:
        itpsFVxMtpqI:
            grant:
                - ALL
            name: cloverbox
            host: localhost
            user: homestead
            password: secret
            sql_file: ''
postgresql:
    install: '1'
    settings:
        root_password: secret
        user_group: postgres
        encoding: UTF8
        version: '9.3'
    databases: {  }
    adminer: 0
mariadb:
    install: '0'
    override_options: {  }
    root_password: '123'
    adminer: 0
    databases: {  }
    version: '10.0'
sqlite:
    install: '1'
    adminer: 0
    databases: {  }
mongodb:
    install: '0'
    settings:
        auth: 1
        port: '27017'
    databases: {  }
redis:
    install: '1'
    settings:
        conf_port: '6379'
mailcatcher:
    install: '1'
    settings:
        smtp_ip: 0.0.0.0
        smtp_port: 1025
        http_ip: 192.168.10.10
        http_port: '1080'
        mailcatcher_path: /usr/local/rvm/wrappers/default
        from_email_method: inline
beanstalkd:
    install: '1'
    settings:
        listenaddress: 198.162.10.10
        listenport: '13000'
        maxjobsize: '65535'
        maxconnections: '1024'
        binlogdir: /var/lib/beanstalkd/binlog
        binlogfsync: null
        binlogsize: '10485760'
    beanstalk_console: '1'
    binlogdir: /var/lib/beanstalkd/binlog
rabbitmq:
    install: '0'
    settings:
        port: '5672'
elastic_search:
    install: '0'
    settings:
        version: 1.4.1
        java_install: true
solr:
    install: '0'
    settings:
        version: 4.10.2
        port: '8984'

该提问来源于开源项目:puphpet/puphpet

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

12条回答 默认 最新

  • weixin_39535287 weixin_39535287 2021-01-10 06:26

    Please show your configuration of MySQL Workbench. Which credentials have you used?

    It works for me with this settings:

    SSH Username: root SSH Key File: /path/to/vagrant/box/puphpet/files/dot/ssh/id_rsa

    Have you tried to disable the rules for firewall?

     yaml
    firewall:
        install: '1'
        rules: 
            rMco8Q6yzyFV:
                port: '3306'
                priority: '100'
                proto: tcp
                action: accept
    

    to

     yaml
    firewall:
        install: '1'
        rules: null
    
    点赞 评论 复制链接分享
  • weixin_39968722 weixin_39968722 2021-01-10 06:26

    Having the same problem, my firewall config rules are "null".

    点赞 评论 复制链接分享
  • weixin_39948442 weixin_39948442 2021-01-10 06:26

    Hi , thanks for your reply.

    In fact, yesterday I'd discover that the problem only happens in Ubuntu using MySql Workbench. When I came home I tried using the same phphpet config in my Mac using SequelPro and everything works just fine.

    I'm connecting using:

    MySql host: 127.0.0.1 MySql username: root MySql password: 123456 SSH host: 127.0.0.1 SSH user: vagrant SSH Key: /path/to/my/puphpet/files/dot/ssh/id_rsa SSH port: 9004 (that is my port forward)

    点赞 评论 复制链接分享
  • weixin_39535287 weixin_39535287 2021-01-10 06:26

    Hmm, I'm using the id_rsa with root and it works fine. But it does not work for me with vagrant and id_rsa.

    点赞 评论 复制链接分享
  • weixin_39948442 weixin_39948442 2021-01-10 06:26

    Unfortunately, even using root I can't connect. I think that is a problem with Ubuntu.

    点赞 评论 复制链接分享
  • weixin_39926749 weixin_39926749 2021-01-10 06:26

    I have the same problem: Workbench can't connect, but with Valentina Studio could.

    Don't know what to do.

    点赞 评论 复制链接分享
  • weixin_39929961 weixin_39929961 2021-01-10 06:26

    I have the same problem

    点赞 评论 复制链接分享
  • weixin_39957027 weixin_39957027 2021-01-10 06:26

    I had a very similar problem. The issue with connecting via SSH tunnel was caused by id_rsa not being private enough. Try chmod 400 id_rsa and try to connect again.

    点赞 评论 复制链接分享
  • weixin_39523280 weixin_39523280 2021-01-10 06:26

    Hey everyone, I figured it out via this link, so I thought I would share- https://slewsystems.wordpress.com/2014/01/01/connecting-to-a-puphpet-vagrant-ftp-and-mysql-servers/

    The problem is that the SSH Host has to the be the IP of the VM you set up, with User being Vagrant.

    So for SequelPro I used-

    Name:localhost MySQL Host : 127.0.0.1 Username: (check your config.yaml) Password: (check your config.yaml) Database: (Optional, but if you set one up, throw the name in if you want to connect directly to it) Port: 3306

    SSH Host: (The IP on your VM) SSH User: Vagrant SSH Key: path to your id_rsa file SSH Port: I left this blank

    The details should be the same for MySQLWorkbench and others as described in that link.

    点赞 评论 复制链接分享
  • weixin_39687621 weixin_39687621 2021-01-10 06:26

    I had a very similar problem. The issue with connecting via SSH tunnel was caused by id_rsa not being private enough. Try chmod 400 id_rsa and try to connect again.

    This is most likely it. I'll add a note to the gui

    点赞 评论 复制链接分享
  • weixin_39819138 weixin_39819138 2021-01-10 06:26

    After a few hours of frustration it turned out I was using id_rsa.ppk as my key file and not id_rsa (no extension) to connect with MySQL Workbench.

    点赞 评论 复制链接分享
  • weixin_39816024 weixin_39816024 2021-01-10 06:26

    Choose Standard TCP/IP over SSH

    Parameters (Mostly default values since I did not change it)

    SSH Hostname: 192.168.56.101 SSH Username: vagrant SSH Password: vagrant SSH Key File: C:\cygwin64\home\tomy\puphpet\sutfva\puphpet\files\dot\ssh\id_rsa MySQL Hostname: 127.0.0.1 MySQl Server Port: 3306 Username: root Password: 123

    点赞 评论 复制链接分享