mysqlubuntuvagrantvirtualboxhomestead

Virtual Box ( ubuntu, vagrant, homestead ) sites connect to host database (ubuntu, mysql)


I am pretty new to VirtualBox or network, port forward, etc. I am just a front-end Developer.

I want to connect the MySQL databases in my host os running ubuntu, to the websites running in virtual box (vagrant, homestead, ubuntu 20.04).


Solution

  • First of all, in order to connect your virtual box to MySQL db you have to modify the Homestead.yaml file. I am giving you an example below.

    Homestead.yaml example

    Then, what do you exactly want to do? I suppose you have a project and you want to connect it with MySQL db? Maybe, a .env file where you can put the db connection credentials. For example: .env file example