使用Sequel Pro在Vagrant实例上连接到MySQL [英] Connect to MySQL on Vagrant instance with Sequel Pro

查看:75
本文介绍了使用Sequel Pro在Vagrant实例上连接到MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Vagrant上运行Laravel,并且试图连接Sequel Pro.

I am running Laravel on Vagrant and I am trying to connect Sequel Pro.

我刚开始使用Vagrant,我遵循了一些有关连接到Sequel Pro的教程,但是都失败了.

I have just started using Vagrant, I have followed a few tutorials on connecting to Sequel Pro however they were all unsuccessful.

这是我的流浪文件:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure('2') do |config|
config.vm.hostname = 'laravel'
config.vm.boot_timeout = 3600
config.vm.box = 'debian-73-i386-virtualbox-puppet'
config.vm.box_url = 'http://puppet-vagrant-boxes.puppetlabs.com/debian-73-i386-virtualbox-puppet.box'

config.vm.network :forwarded_port, guest: 8000, host: 8000
config.vm.network :forwarded_port, guest: 8500, host: 8500

config.vm.provider :virtualbox do |vb|
vb.customize ['modifyvm', :id, '--memory', '1536']
end

config.vm.provision :puppet do |puppet|
puppet.manifests_path = 'puppet/'
puppet.manifest_file  = 'init.pp'
puppet.module_path    = 'puppet/modules/'
# puppet.options      = '--verbose --debug'
end

end

来自my.cnf:

bind-address            = 127.0.0.1 

这是我的/etc/hosts

127.0.0.1       localhost
127.0.1.1       laravel
# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

将绑定地址更改为0.0.0.0仍然不起作用 在Sequel Pro中,我有

changed bind address to 0.0.0.0 still does not work In Sequel Pro I have

MySQL Host: 0.0.0.0
username: root
Password: (mysql password)
SSH Host 0.0.0.0
SSH User: vagrant
SSH Password: vagrant

这是我无所事事的主机文件-etc/hosts

Here is my vagrant hosts file - etc/hosts

这是我的主机文件

127.0.0.1       localhost
127.0.1.1       laravel
# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

推荐答案

问题在于,您在my.cnf中设置的MySQL现在只能通过Vagrant服务器中的localhost连接:

The issue is that MySQL as you have it setup in my.cnf now can only connect via localhost within the Vagrant server:

bind-address            = 127.0.0.1 

要在MySQL中启用联网,应将my.cnf中的设置更改为:

To enable networking in MySQL, you should change that setting in my.cnf to:

bind-address            = 0.0.0.0

然后重新启动MySQL服务.不确定在Vagrant中会如何发生,但是在Ubuntu中,您将输入如下命令:

And then restart the MySQL service. Unsure of how that would happen in Vagrant, but in Ubuntu you would enter a command like this:

sudo service mysql restart

您可能必须检查您的MySQL用户权限,以确保实际上可以从任何IP地址使用MySQL中的用户(有时也将它们严格设置为localhost127.0.0.1).

You might have to check your MySQL user permissions to ensure that the user within MySQL can actually be used from any IP address—sometimes they are set strictly to localhost or 127.0.0.1—as well.

MySQL官方文档中所述:

服务器按以下方式处理不同类型的地址:

The server treats different types of addresses as follows:

  • 如果地址为0.0.0.0,则服务器在所有服务器主机IPv4接口上接受TCP/IP连接.

  • If the address is 0.0.0.0, the server accepts TCP/IP connections on all server host IPv4 interfaces.

如果地址为::,则服务器在所有服务器主机IPv4和IPv6接口上接受TCP/IP连接.使用此地址允许两个 所有服务器接口上的IPv4和IPv6连接.

If the address is ::, the server accepts TCP/IP connections on all server host IPv4 and IPv6 interfaces. Use this address to permit both IPv4 and IPv6 connections on all server interfaces.

如果该地址是IPv4映射的地址,则服务器接受该地址的IPv4或IPv6格式的TCP/IP连接.为了 例如,如果服务器绑定到:: ffff:127.0.0.1,则客户端可以 使用--host = 127.0.0.1或--host = :: ffff:127.0.0.1.进行连接

If the address is an IPv4-mapped address, the server accepts TCP/IP connections for that address, in either IPv4 or IPv6 format. For example, if the server is bound to ::ffff:127.0.0.1, clients can connect using --host=127.0.0.1 or --host=::ffff:127.0.0.1.

如果该地址是常规" IPv4或IPv6地址(例如127.0.0.1或:: 1),则服务器仅接受该IPv4或IPv6地址的TCP/IP连接.

If the address is a "regular" IPv4 or IPv6 address (such as 127.0.0.1 or ::1), the server accepts TCP/IP connections only for that IPv4 or IPv6 address.

那是不建议将MySQL或任何数据库服务器公开的.但是在这样的地方发展情况下是可以接受的.

That said, exposing MySQL—or any database server—to the world is not advisable. But is acceptable in a case of local development like this.

因此,如果不能启用MySQL网络功能,则还可以使用Sequel Pro中的内置SSH隧道功能通过SSH连接到MySQL.有关所有不同连接类型的详细信息,请参见官方Sequel Pro网站在这里.但是此屏幕截图很好地总结了这一点.

So if enabling MySQL networking is not an option, you can also use the built in SSH tunneling capabilities in Sequel Pro to connect to MySQL via SSH. Details on all of the different connection types are shown on the official Sequel Pro site here. But this screenshot sums it up nicely.

基本上,您只需像通常那样设置localhost/127.0.0.1 MySQL信息即可.但是,您还可以将用于SSH的SSH信息添加到服务器中.并且Sequel Pro将使用该SSH连接在&中建立隧道.无缝连接到MySQL.这可能是更好的处理方式,而不是与MySQL网络&用户权限问题.

Basically you just set your localhost/127.0.0.1 MySQL info as you normally would. But you also add the SSH info you would use to SSH into your server. And Sequel Pro will use that SSH connection to tunnel in & connect to MySQL seamlessly. This might be the better way to handle instead of dealing with MySQL networking & user permission issues.

对于Sequel Pro中的SSH隧道,您只需执行以下操作:

For SSH tunneling in Sequel Pro you just need to do the following:

  • 名称:您要用于连接的名称.
  • MySQL主机:MySQL主机的IP地址,应为localhost127.0.0.1
  • 用户名: MySQL数据库用户名.
  • 密码:与该MySQL数据库用户名关联的密码.
  • 数据库:可选(您要连接的数据库)
  • 端口:默认值为3306,因此只有在您必须设置为其他任何设置时,才应更改此设置.
  • Name: The name you want for the connection.
  • MySQL Host: The IP address of the MySQL host which should be localhost or 127.0.0.1
  • Username: MySQL database username.
  • Password: The password connected to that MySQL database username.
  • Database: Optional (database you want to connect to)
  • Port: Default is 3306 so only change this if you definitely have to set to anything else.

现在,您在这里为Vagrant安装设置SSH设置:

Now here you set the SSH settings for your Vagrant install:

  • SSH主机:您的Vagrant计算机的主机名或IP地址.
  • SSH用户:该Vagrant计算机的SSH用户名.
  • SSH密码:与该SSH用户连接的密码.
  • SSH端口:,默认值为22,因此只有在您必须设置为其他任何设置时,才应更改此设置.
  • SSH Host: The hostname or IP address of your Vagrant machine.
  • SSH User: The SSH username to that Vagrant machine.
  • SSH Password: The password connected to that SSH user.
  • SSH Port: Default is 22 so only change this if you definitely have to set to anything else.

这篇关于使用Sequel Pro在Vagrant实例上连接到MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆