In this post we’re going to cover several ways to install a complete MySQL Environment. You have several overlapping options depending on the operating system you’re using. You only need ONE. Here’s a list of options:

Windows Users: Installing MySQL with WampServer

WampServer is great because it gives you a FULL MySQL Environment. You’ll have the apache webserver, MySQL, and PHP all setup for you. Here’s how to set everything up.

Mac OS X Users: Installing MySQL with Mamp

Mamp also gives you a full MySQL Environment, but for Mac instead! Here’s a video on how to install:

Any System: Installing MySQL with XAMPP

I recommend you use either Mamp or Wamp if you can, but if for whatever reason you want to use XAMPP, here’s how you can set it up.

Any System: MySQL using Docker

This is an OLD section and have not verified its accuracy. I assume you have Docker installed if you’re going with this installation method. Here’s how to setup a MySQL environment in Docker.

We’ll be using Adminer and MySQL instead of Xampp. (I highly recommend Adminer over Xampp when using Docker!)

Setting up a MySQL environment is super easy in Docker.

First, make sure you’ve got docker-compose setup so you can use the docker-compose command.

I got most of the code needed right on the Docker page for Mysql: Docker hub’s Mysql page.

The only thing we need to add is “persistence”. Every time you start and stop a docker container, it’s going to use a different “Volume” meaning your database information will not be re-used. You probably don’t want to start from scratch every time, so we need to use a volume.

Create a directory for your project, and create a docker-compose.yml file inside the project directory. Inside the docker-compose.yml file, paste the following code:

# Use root/example as user/password credentials
version: '3.1'

services:

db:
image: mysql
restart: always
volumes:
- learnMysql:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: example

adminer:
image: adminer
restart: always
ports:
- 8080:8080
volumes:
learnMysql:

Now in a terminal, or whatever GUI docker may give you, run $ docker-compose up to start the project. When it’s finished loading you can visit localhost:8080 to visit Adminer, where you can handle all your database interactions.

The username for adminer is root

The password for adminer is example

When you’re done for the day, run $ docker-compose down to turn off the docker container.

Here’s a brief explanation of the above code.

version: ‘3.1’ – Version of docker-compose

services: – begins list of “services” in the docker project.

db: – service name is “db”
image: mysql – uses the mysql image. (all code to use mysql)
restart: always – restart if container is stopped.
volumes: – list of volumes
– learnMysql:/var/lib/mysql – mount “learnMysql” volume to container’s /var/lib/mysql so we can re-use our database information.
environment:
MYSQL_ROOT_PASSWORD: example – environment variable.

adminer: – service name is adminer
image: adminer – uses adminer image
restart: always – restarts if stopped.
ports:
– 8080:8080 – map port from local machine to adminer container. so we can access it on our machine.
volumes:
learnMysql: – choose the name for our database volume.

Nice and simple right? That’s it!

On a VM?: Install XAMPP on Mac with Xampp-VM

This is a very old tutorial, and I’m not sure the benefits or why you’d want to install XAMPP on a Virtual Machine, but if you’d like to take a stab at it for whatever reason, be my guest. No guarantee this will work or that you’d even want to try. Here’s how to use XAMPP’s Virtual Machine implementation of xampp: