How to run MySQL on an Ubuntu Virtual Machine (NAT configuration) and access it through phpMyAdmin on the host OS
1.[Install MySQL and phpMyAdmin on the Ubuntu Server VM]
sudo apt update
sudo apt install mysql-server phpmyadmin2.[Configure VirtualBox network settings]
Forward the host’s port 8080 to the guest’s port 80. Unplug and replug the network cable in the VM’s network settings UI to apply changes.
3.[If UFW (firewall) is enabled on the VM, allow MySQL port]
sudo ufw allow 3306/tcp
sudo ufw reload4.[Link phpMyAdmin to Apache]
sudo ln -s /usr/share/phpmyadmin /var/www/html
sudo systemctl restart apache25.[Change MySQL root user authentication to use password]
sudo mysql -u root
**Inside MySQL shell:**
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_new_password';
FLUSH PRIVILEGES;
EXIT;
**Then restart MySQL:**
sudo systemctl restart mysql6.[Access phpMyAdmin on host OS]
Open your browser and visit:
http://localhost:8080/phpmyadmin/
- Replace 'your_new_password' with a strong password you choose.
- Make sure your VM network is set to NAT for port forwarding to work.
- This setup assumes Apache is your web server.
This project is licensed under the MIT License. See the LICENSE file for details.