Add MySQL Docker Image to Unraid
In the previous post, I walked you through setting up your Unraid server to pull images from Docker Hub and also set it up so each Docker container will receive its own IP address. Now let’s install MySQL and connect to it.
Install MySQL Container
Go to your “Apps” tab in Unraid and search for MySQL. The first screen is results for Unraid plugins, but we don’t want those.
Near the top of the search results is a link to search Docker Hub, click that. The screen should now show images that are available on Docker Hub.
The very first result is the official Oracle MySQL image, click the download icon. After you do this, you’ll be taken to a setup screen.
Switch to the Advanced View by clicking on the toggle in the upper-right corner of the screen.
Here is where we’ll configure our container by setting the root password, defining the network, and path for our databases. But first, we need to figure out what our network name is. To do this, open up the terminal by clicking on the “Terminal” link on the right side of the menu bar at the top of the screen. You should see a new window open that looks like a terminal. Now type “docker network ls”. This will list all of Docker’s network configurations. In the last post we created a “macvlan” network. We need the name of it. In the picture below you’ll see that mine is “br0”.
Now go ahead and close this window by typing “exit”. You’ll be placed back on the MySQL container configuration screen. Change the network type to “None” then set the “Extra Parameters” property to “–network ” (that’s a double-dash then ‘network’) followed by the network name from above (e.g. “–network br0”).
Next, we need to tell the container where we’re going to store our database files. If you don’t set this path it will keep the databases off of your shared network and inside of the container. It’s up to you if you prefer this or not. If you’d prefer the databases to remain inside your container and not accessible via your file share, go ahead and skip this step.
Add a “Path” property and set the “Container Path” to “/var/lib/mysql” and the “Host Path” to a shared folder on your network.
Finally, add a new property called “MYSQL_ROOT_PASSWORD”. This property is required by the container and will not start up unless it is present. The value can be anything you like. Just make sure it’s secure enough for your needs.
After that, click apply and Unraid will start downloading the MySQL image from Docker Hub.
Connecting to MySQL
Once that’s done, you’ll see the container has started on the Docker tab:
It’s now ready to use!
Be aware that since the image is using a newer version of MySQL, that if you’re using the current release of MySQL Workbench that you will not be able to connect to it due to an “Authentication plugin ‘caching_sha2_password’ cannot be loaded” error. The reason for this is that Workbench doesn’t support the password hashing algorithms enabled by default in MySQL.
You could disable these in MySQL, or you can just download a newer release of MySQL Workbench.
That’s all you need to do to set up MySQL on Unraid. Let me know if you have any questions, problems, or corrections.