VirtualBox Vagrant 내에서 Mysql Server에 연결하는 방법은 무엇입니까?
Vagrant를 사용하여 VirtualBox Machine을 마운트하고 해당 VM에 Mysql Server를 설치했습니다. VM 외부의 해당 서버에 어떻게합니까? 이미 Vagrantfile의 포트 3306을 전달했지만 mysql 서버에 연결하려고하면 'reading initial communication packet'오류와 함께 다시 게시됩니다.
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0
MySQL이 127.0.0.1이 아닌 0.0.0.0에 바인딩 검증 확인하십시오. 정렬 시스템 외부에서 액세스 할 수 없습니다.
my.conf 파일을 편집하고 bind-address
항목을 검색하여 확인할 수 있습니다 bind-address = 0.0.0.0
. 그런 다음 저장하고 mysql을 다시 시작하십시오.
sudo service mysql restart
서버에서 작업을 수행하는 경우 https://serverfault.com/questions/257513/how-bad-is-setting-mysqls-bind-address-to에 설명 된 보안 영향을 알고 싶습니다. -0-0-0-0
ssh vagrant@127.0.0.1 -p 2222
(비밀번호 vagrant) 로 귀하의 상자에 로그인하십시오.
그런 sudo nano /etc/mysql/my.cnf
다음 #으로 다음 줄을 주석 처리하십시오.
#skip-external-locking
#bind-address
저장 후 종료
그때 : sudo service mysql restart
그런 다음 SSH를 통해 MySQL 서버에 있습니다.
최근 에이 문제를 발견했습니다. PuPHPet을 사용하여 구성을 생성했습니다.
SSH를 통해 MySQL에 연결되는 "vagrant"암호가 작동하지 않고 대신 SSH 키 파일을 통해 인증해야합니다.
MySQL Workbench에 연결 비용
연결 방법
SSH를 포함하는 표준 TCP / IP
SSH
Hostname: 127.0.0.1:2222 (forwarded SSH port)
Username: vagrant
Password: (do not use)
SSH Key File: C:\vagrantpath\puphpet\files\dot\ssh\insecure_private_key
(Locate your insercure_private_key)
MySQL
Server Port: 3306
username: (root, or username)
password: (password)
연결을 테스트하십시오.
mysql workbench 또는 sequel pro를 사용하여 작업을 수행하려는 사람 다음과 같은 입력이 있습니다.
Mysql Host: 192.168.56.101 (or ip that you choose for it)
username: root (or mysql username u created)
password: **** (your mysql password)
database: optional
port: optional (unless you chose another port, defaults to 3306)
ssh host: 192.168.56.101 (or ip that you choose for this vm, like above)
ssh user: vagrant (vagrants default username)
ssh password: vagrant (vagrants default password)
ssh port: optional (unless you chose another)
출처 : https://coderwall.com/p/yzwqvg
주어진 응답 중 어느 것도 나를 도와 글쎄, 좀 더 지켜 볼 수밖에 없었습니다, 그리고 용액 발견 이 기사를.
간단히 말해서 대답은 다음과 가변합니다.
MySQL Workbench를 사용하여 MySQL에 연결
Connection Method: Standard TCP/IP over SSH
SSH Hostname: <Local VM IP Address (set in PuPHPet)>
SSH Username: vagrant (the default username)
SSH Password: vagrant (the default password)
MySQL Hostname: 127.0.0.1
MySQL Server Port: 3306
Username: root
Password: <MySQL Root Password (set in PuPHPet)>
주어진 접근 방식을 사용하여 MySQL Workbench를 사용하고 Valentina Studio를 사용하여 Ubuntu 컴퓨터에서 vagrant의 mysql 데이터베이스에 많은 수 있습니다.
상자에 로그인 한 후 나를 일한 단계는 다음과 사용할 수 있습니다.
MySQL 구성 파일을 찾습니다.
$ mysql --help | grep -A 1 "Default options"
Default options are read from the following files in the given order: /etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf
Ubuntu 16에서 경로는 일반적으로 /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address에 대한 구성 파일 변경 :
존재하는 경우 다음과 같이 값을 변경하십시오. 존재하지 않는 경우 [mysqld] 섹션의 아무 곳에 나 추가하십시오.
bind-address = 0.0.0.0
구성 파일에 대한 변경 사항을 저장하고 MySQL 서비스를 다시 시작합니다.
service mysql restart
데이터베이스 사용자에 대한 액세스를 생성 / 부여합니다.
루트 사용자로 MySQL 데이터베이스에 연결하고 다음 SQL 명령을 실행합니다.
mysql> CREATE USER 'username'@'%' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON mydb.* TO 'username'@'%';
이것은 나를 위해 일했습니다 : Vagrant에서 MySQL에 연결
username: vagrant password: vagrant
sudo apt-get update sudo apt-get install build-essential zlib1g-dev
git-core sqlite3 libsqlite3-dev sudo aptitude install mysql-server
mysql-client
sudo nano /etc/mysql/my.cnf change: bind-address = 0.0.0.0
mysql -u root -p
use mysql GRANT ALL ON *.* to root@'33.33.33.1' IDENTIFIED BY
'jarvis'; FLUSH PRIVILEGES; exit
sudo /etc/init.d/mysql restart
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
config.vm.box = "lucid32"
config.vm.box_url = "http://files.vagrantup.com/lucid32.box"
#config.vm.boot_mode = :gui
# Assign this VM to a host-only network IP, allowing you to access
it # via the IP. Host-only networks can talk to the host machine as
well as # any other machines on the same network, but cannot be
accessed (through this # network interface) by any external
networks. # config.vm.network :hostonly, "192.168.33.10"
# Assign this VM to a bridged network, allowing you to connect
directly to a # network using the host's network device. This makes
the VM appear as another # physical device on your network. #
config.vm.network :bridged
# Forward a port from the guest to the host, which allows for
outside # computers to access the VM, whereas host only networking
does not. # config.vm.forward_port 80, 8080
config.vm.forward_port 3306, 3306
config.vm.network :hostonly, "33.33.33.10"
end
'IT' 카테고리의 다른 글
다중 선택을 허용하지 않고 HTML로 목록 상자를 만드는 방법은 무엇입니까? (0) | 2020.08.29 |
---|---|
xs : NCName 유형은 무엇이며 언제 언제 사용합니까? (0) | 2020.08.29 |
Objective-C의 약하고 강력한 속성 setter 속성 (0) | 2020.08.29 |
새 줄 또는 탭을 만드는 방법 (0) | 2020.08.29 |
제목 대소 문자로 변환 (0) | 2020.08.29 |