Build Your Homelab: 7 – Databases with MySQL

Homelab 7 - MySQL

Now that we have most of the necessities out of the way in our Homelab, we can start to focus on items that is going to add value to the homelab in general. As an example, WordPress is already running in or homelab, but if is a single container that is responsible for both PHP and MySQL. So today we are going to start looking at splitting our services so that each container or VM is only responsible for one task at a time. Today we are going to get our own separate MySQL server up and running and working, but using a LCX container again (due to its lightweight nature compared to a VM). One of the most valuable additions to any homelab is a MySQL instance, a powerful and widely used relational database system. But why would you want to run MySQL at home? Whether you’re a developer testing applications, a data enthusiast exploring structured storage, or a homelabber setting up self-hosted services like WordPress or Nextcloud, MySQL provides a solid foundation for storing and managing your data.


Step 1: Get the MySQL LXC Container

Log in to your Proxmox web address again and in the left navigation pane expand Datacenter, then expand your main node, ex proxmox. From there select the local directory. In the middle navigation pane, select CT Templates and the click Templates Button in the main window. In the window that pops up, search for MySql and select the search result. Click Download Buttonto start the download process of the LXC Container Template. Once completed, we can create a new instance of this CT Template.


Step 2: Create a new container

Once we have the container template, we can click the Proxmox - Create CT button to create a new container. We need to use the following values:

  • General
    In the general screen, fill in the CT ID field, this can be any number normally in the 100 – 999 range, and this is just an ID for the container. Fill in the hostname (mysql) and choose a password. This password is the password for the rootuser of the Linux container.
  • Template
    In the template screen, select the container template. You should only have the option to select localin the Storage dropdown as that is the only place where container templates are installed. In the Template field, select the mysql container template we downloaded in step 1.
  • Disks
    Now we come to the location where the container will be installed. Select any disk of your choosing and disk size as well. The default 8GB of storage is more than enough for now, but we will grow into it as we run more services. We are going to increase this to 20GB for now, we can increase more later.
  • CPU
    This is just the maximum amount of CPU cores the container has access to. This does not mean that those cores are onlyassigned to this container, it merely states that the container cannot access more than these. We opted for 4 so that we can handle multiple databases at the same time when needed.
  • Memory
    Same as CPU, this states the maximum. We are increasing this to 4GB, we will probably need more later on but for now we will have plenty.
  • Network
    Leave as is and just continue to the next screen.
  • DNS
    Again, leave as Use Host Settings, we might change this in a future container or VM, but seeing as we don’t even have our own DNS server up and running yet (At the time of writing), there is no need to change this.
  • Confirm
    Check that you are happy with all of the settings, and if you are, hit Proxmox - Finish. The installer will run and let you know once done.

Step 3: Configure Container

Select the newly created container from the left navigation pane. If it is not running, click Start to start up the container. From the middle navigation pane, select Console to open the integrated console. Log in with the username root and the password selected in the General section of step 2.

A graphical screen will now open and prompt you a couple of things. Firstly, provide a password for Adminer (this is the web page used for the Turnkey LXC Container admin). After providing a password, and confirming the password, you will be asked to provide a password for the MySQL ‘remote’ user. Note that you can also log in with the adminer user with the password you selected previously. After entering a password, and confirming it, for the remote user, you will be prompted for the Turnkey Backup and domain management key again. Skip this for now and more to the next screen where you will be prompted if you want to received emails with security updates. Decide if you want, and move to the next screen. You will be prompted if you want to install the latest security updates. It is always a good idea to do so. Once install in completed, you will be shown the screen with the connection details. Take note of the adminer url as well as the IP address of the server. In the Advanced Menu you can just quit.

Step 4: Connect via SQL Workbench

If you have MySQL Workbench installled, we can do a quick setup and connection test to ensure everything is working. If you don’t have it installed, you can get it from https://www.mysql.com/products/workbench/ Click the + icon next to MySQL Connections to create a new connection. Enter a connection name, enter the IP address and enter remote as the user. Click Store in Vault in the password section to enter the password. If you get a warning about version mismatches, just continue. Hopefully you will get the connection success message, which means that everything is working as expected.

Screenshot 2025-03-10 141219

MySQL Connection Details

Screenshot 2025-03-10 141224

Store Password in Vault

Screenshot 2025-03-10 141310

If you get the Connection Warning screen, just click the Continue Anyway button

Screenshot 2025-03-10 141315

Connection Success Messagebox


Bonus Step

If you want, you can also access your Technitium DNS server and add a new record that points to the IP address of the MySQL node. This means that you can just use mysql.local in stead of using the IP address. There is no need to use our NGINX Reverse Proxy for this.

Screenshot 2025-03-10 142308

Adding a mysql record to the local zone so that we can use mysql.local. Note that the IP address of the MySQL container has changed because we added Address Reservation for the MySQL on the router to ensure we get the same IP address every time it restarts.


Conclusion

Now that we have our own MySQL instance up and running, we will be able to deploy services a lot faster that depends on it. We will also be able to be in control of the resource usage of the entire instance, which means we don’t have overheads of individual instances. This means better performance when running multiple apps and better control over resource usage.

In a future article, we will be installing WordPress (Again) but this time from a manual install, using this MySQL instance for the database in stead of running a separate one in the WordPress Container.