How to Add MySQL Port Forwarding Rule to access MySQL Database Server of Guest Machine running in VirtualBox Manager from Host Machine

Posted on

Introduction

This article will show how to how to access MySQL Database Server’s service running in a virtual server. The virtual server where in several occasion has a term of ‘Guest Machine’ is running the service. So, a virtual machine manager in this context is VirtualBox application is emulating the virtual server. So, the objective is to be able to access database server provided by a MySQL service from a host machine. The definition of a host machine is to point out the machine runs the VirtualBox application. So, in order to be able to do it, one of the solution is just by adding a new rule for the port forwarding. It exist on the virtual server runs with a NAT type adapter.

Adding MySQL Port Forwarding Rule in the Virtual Server Setting

The following are steps for adding MySQL port forwarding rule in a CentOS virtual server :

1. Because the VirtualBox application is emulating the virtual server, run the VirtualBox Manager first. The following image is displaying the VirtualBox Manager :

How to Add MySQL Port Forwarding Rule to access MySQL Database Server of Guest Machine running in VirtualBox Manager from Host Machine

The above image displaying the default VirtualBox application where there is no single virtual server available at all. If the virtual server is available, there will be an icon of that virtual server in the left side as in the next step.

2. Next, in the following step, just select the suitable virtual server in the VirtualBox application exist in the following image :

How to Add MySQL Port Forwarding Rule to access MySQL Database Server of Guest Machine running in VirtualBox Manager from Host Machine

3. Select the virtual server for further configuration and right click on it to get to the Settings Windows Dialog Box. The following image picturing Settings Window box of that virtual server will appear :

How to Add MySQL Port Forwarding Rule to access MySQL Database Server of Guest Machine running in VirtualBox Manager from Host Machine

4. After that, click the Port Forwarding button as in the above image. The following image of the Port Forwarding Rules Window box will appear :

How to Add MySQL Port Forwarding Rule to access MySQL Database Server of Guest Machine running in VirtualBox Manager from Host Machine

5. Last but not least, add a new rule for forwarding incoming request from a port in the Host Machine. It will forward or redirect the request to a port in the Guest Machine. Port Forwarding is an utility for helping to access a service available in the CentOS virtual server. Just click the Plus Sign, the following image will appear :

How to Add MySQL Port Forwarding Rule to access MySQL Database Server of Guest Machine running in VirtualBox Manager from Host Machine

6. Configure the entry Port Forwarding in the new added line as in the above image as follows :

How to Add MySQL Port Forwarding Rule to access MySQL Database Server of Guest Machine running in VirtualBox Manager from Host Machine

Actually, the rule exist in the last line. It is on the third line because there are already previous rules available. In the last line, it defines that every connection that come from port 9933 in the local host where the VirtualBox application run, it will be forwarded to the Virtual Server IP Address of 10.0.2.15 in port 3306. So, any accesses to that destination will go through the MySQL Database Server port running in 3306. The host machine port is using 9933 just for an example. Do not forget to click the OK button to finish the configuration process.

Leave a Reply