Skip to main content
  1. Programming/

Install MySQL On Manjaro Linux

·3 mins
Photo by @matti_johnson from Unsplash

Manjaro/Arch Linux has no smooth way to install MySQL server since they dropped support of it and replaced it with MariaDB. It is an excellent alternative of MySQL and works absolutely fine. But sometimes you just need MySQL server itself.

There is a AUR package for MySQL which — from my experience — doesn’t go well often 😏. It builds from source and I couldn’t do it after waiting an hour or so. The alternate easiest way to have MySQL in your system is installing it via docker. Let’s begin.

Install docker #

Installing docker on Manjaro is similar like installing any other standard packages.

sudo pacman -Syu
sudo pacman -S docker

Next, you should enable docker service.

sudo systemctl start docker.service
sudo systemctl enable docker.service

Create volumes #

These are storage for keeping your data. Let’s create two volumes, one for MySQL and another for phpMyAdmin.

docker volume create mysql-volume
docker volume create phpmyadmin-volume

This will create a volume for the MySQL container.

If you want to remove a volume for some reason run:

docker volume rm <volume_name>

Creating/Running containers #


To create the MySQL container run:

docker run --name=mysql-8.0 -p3306:3306 -v mysql-volume:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=root -d --restart unless-stopped mysql/mysql-server:8.0.29

Here we are using MySQL image version 8.0.29.

  • --name flag sets a name for the container.
  • -p3306:3306 is telling it to bind host port 3306 to the container port 3306.
  • -v flag attaches the created volumes with the container.
  • -e flag sets a environment variable MYSQL_ROOT_PASSWORD to set the root password which we will be using to login. The user name is root by default.
  • -d flag tells the container to run in detached mode, so that it keeps running even after the command is exited.
  • --restart unless-stopped option tells the container to keep running even when the computer restarts.
  • Finally we provide the image name with the tag we want.

phpMyAdmin #

With the MySQL container created and running, let’s create the phpMyAdmin container:

docker run --name=phpmyadmin -v phpmyadmin-volume:/etc/phpmyadmin/ --link mysql-8.0:db -p 8080:80 -d --restart unless-stopped -e UPLOAD_LIMIT=50M phpmyadmin/phpmyadmin

Here most of the flags are same. Except,

  • --link flag tells it to link the MySQL container with phpMyAdmin.
  • -e sets an UPLOAD_LIMIT environment variable set the upload limit to 50 megabytes for phpMyAdmin.
To bind with docker container’s port 80 we choose port 8080 of the host machine, you can choose any port you want.

Health check #

If both containers are successfully created, run following command to list out running containers:

docker ps

To stop any container run:

docker stop <container_name_or_id>

And to start it:

docker start <container_name_or_id>

To delete a container:

docker rm <container_name>

Access and additional configuration #

To enter into a container run:

docker exec -it <container_name> bash

Now we need to change MySQL connection restriction so that our host machine can connect to it because by default MySQL disables this for security purpose. To do that, first enter into the MySQL container, then run:

mysql -u root -p

Then enter the password (in this root) and we will land into MySQL console. Run:

update mysql.user set host = '%' where user='root';

Restart the containers and hit http://localhost:8080. You’ll see phpMyAdmin is waiting for you! 🗃️ You would only need to do all these steps only once, your containers will keep running unless stopped manually.