Skip to content
Public template

About

An accelerator to readily create and run MariaDB (Mysql) in Docker. This also builds phpMyAdmin in docker for accessing the MariaDB (Mysql) server.

Topics

Resources

Stars

0 stars

Watchers

2 watching

Forks

Repository files navigation

mariadb_docker

A script to readily create and run MariaDB in Docker. This also builds phpMyAdmin in docker for accessing the MariaDB (Mysql) server.

Requirements

Environment variables

There are default values for the MariaDB docker container name, the port that MariaDB uses, the Mysql username, the Mysql password, and the root Mysql password. These may be overridden by setting the following environment variables (see more details on MariaDB/Mysql specific environment variables here):

  • MARIADB_VERSION
    The version of MariaDB/Mysql. (The default is latest)

  • MARIADB_CONTAINER
    The MariaDB/Mysql docker container name. (The default is mariadb-docker)

  • MARIADB_PORT
    The port used by MariaDB/Mysql. (The default is 3306)

  • MYSQL_DATABASE
    Specifies the name of a database to be created on image startup. (The default is no initial database.)

  • MYSQL_USER
    The MariaDB/Mysql username. (The default is mariadb. This should be fine for development, but PLEASE use best practices and change for any deployment.)

  • MYSQL_PASS
    The MariaDB/Mysql password. (The default is docker. This should be fine for development, but PLEASE use best practices and change for any deployment.)

  • MYSQL_ROOT_PASSWORD
    The root MariaDB/Mysql password. (The default is docker. This should be fine for development, but PLEASE use best practices and change for any deployment.)

There are default values for the phpMyAdmin docker container and the port that phpMyAdmin uses. These may be overridden by setting the following environment variables:

  • PMA_CONTAINER
    The phpMyAdmin docker image name. (The default is pg-admin)

  • PMA_PORT
    The port used by phpMyAdmin. (The default is 8081)

  • PMA_UPLOAD_LIMIT
    The default upload limit (for importing SQL). (The default is 10M)

Once created these containers may be accessed via a network. The default network is called mariadb. This may be overridden by setting the following environment variable:

  • MARIADB_NETWORK
    The network the containers can be reached on. (The default is mariadb). From the host machine, the DB is in localhost, within the container (ie. from phpMyAdmin) the DB is found at this location.

A .env file may be placed in the same folder as this script to set environment variables. An example of the content of the .env may look like:

MARIADB_NETWORK=my_different_network

PMA_PORT=4242

.env-sample may be used as a template. Simply run:

cp .env-sample .env

start.sh

This creates docker containers for a mysql database and phpMyAdmin. The data persists across container restarts, it is stored in Docker.

Running this script without overriding any variables (see above) should work just fine for a development environment.

Example usage:

To start the containers, simply call:

./start.sh

If a rebuild is desired, pass the "build" flag, --build or simply -b:

./start.sh --build

or simply

./start.sh -b

If environment variables need to be reset to defaults (with .env overrides), pass the "reset_env" flag, --reset_env or simply -r:

./start.sh --reset_env

or simply

./start.sh -r

stop.sh

This script will stop the containers. They can be restarted with the start.sh script and the data will persist.

Example usage:

./stop.sh

The default root user is root. That user will have ALL the privileges. The MYSQL_USER will be granted all access (corresponding to GRANT ALL) to the MARIADB_DATABASE database.

About

An accelerator to readily create and run MariaDB (Mysql) in Docker. This also builds phpMyAdmin in docker for accessing the MariaDB (Mysql) server.

Topics

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages