How To Install WordPress in Docker using Docker Compose

I follow  How to install WordPress in Docker Tutorial and found it has error in its docker-compose.yml file. Besides, it didn’t tell how to access phpMyAdmin and WordPress.

I am completely newbie on Docker so it took me time to really understand.

For that reason, I copy the tutorial and improve and simplify it. So it is easier for newcomer to Docker.

How To Install WordPress in Docker Using Docker Compose?

Create a folder for your project

Create a docker-compose.yml file inside your folder

 

Run The Docker WordPress Installation

Run Docker Compose Command Same Location as Your docker-compose.yml

docker - wordpress run compose up
docker – wordpress run compose up

Access WordPress

Run the usual WordPress Installation

wordpress installation page
wordpress installation page

Database Configuration:

Database name: wordpress
Username: wordpress
Password: wordpress

Testing Your WordPress Installation in Docker

Login using username and passoword, you have created. Then insert a post.

docker creating a post in wordpress
docker creating a post in wordpress

Check at phpMyAdmin

Server: <leave it empty>
Username: WordPress
Password: WordPress

docker phpmyadmin username and password wordpress
docker phpmyadmin username and password wordpress

Check Inserted Data

docker - new post successfully inserted in database
docker – new post successfully inserted in database

Last Note

With this docker-compose configuration you can’t access to your local file system. So this another thing I need to find the solution.

 

Import SQL File into MySQL in XAMPP from Command Line in MacOS

To import SQL file in XAMPP MySQL, first has to go to XAMPP MySQL bin then do the command standard Mysql import command line.

XAMPP Path in MacOS

Command in Terminal

Example:

XAMPP mysql import sql file

 

Access XAMPP 8.2.4 MySQL via Command Line in MacOS

You can access XAMPP 8.2.4 MySQL via command line in MacOS by following these steps.

1. Go to XAMPP 8.2.4 MySQL folder in MacOS

2. Type This Command

If successful, XAMPP will connect to MariabDB instead of MySQL

You can double check by getting all databases in the MariaDB.

 

macos xampp 8.2.4 mysql access via command line
macos xampp 8.2.4 mysql access via command line

MySQL Upload / Import Database via Command Line using Ubuntu 22

I imported / uploaded SQL database with file size of 210MB and 347MB via Ubuntu v22 terminal command line.

My MySQL version is: 8.0.32

mysql sql file size of 210mb
mysql sql file size of 210mb
mysql sql file size of 347mb
mysql sql file size of 347mb

The Command Line

How Long it took to Import The Data?

Below is the time it took to upload the data.

210MB: 20s
347MB: 1m30s

 

Macbook M1 MacOS Big Sur Error MySQL PhpMyAdmin When Login

I login to MySQL using phpMyAdmin with root account and it produced this error.

Login root via terminal

I was able to login using my root password means something configuration is not correct.

macbook M1 mysql login via terminal
macbook M1 mysql login via terminal

When I googled, I found 2 solutions. I tried the first one but fail. So I documented the one that works with Macbook M1 MacOS Big Sur.

Update root Password via Terminal

Login Again At Your phpMyAdmin

It should work by now using root and the updated password.