docker-lamp icon indicating copy to clipboard operation
docker-lamp copied to clipboard

MySQL doesn't start when a local volume is used

Open cbitterfield opened this issue 5 years ago • 1 comments

MySQL doesn't start when I configured a local volume for persistence. Also: When it starts, the SQL files are created in /var/lib/mysql as root:root:

root@7a9ca27a41f7:/# service mysql status
 * MariaDB is stopped.

Usage: /etc/init.d/mysql start|stop|restart|reload|force-reload|status
root@7a9ca27a41f7:/# service mysql start
 * Starting MariaDB database server mysqld
   ...fail!

I'd recommend:

a. changing the TERM default to "TERM=xterm-256color" which is the mac default. Dumb doesn't work well on MACs. I will put a pull request for the change.

b. I'd add a variable MYSQL_BIND_ADDRESS to override the 127.0.0.1 inside.

/var/lib/mysql# ls -la

drwxr-xr-x 7 root root      224 Nov 20 17:21 .
drwxr-xr-x 1 root root     4096 Apr  3  2019 ..
-rw-rw---- 1 root root     8192 Nov 20 17:21 aria_log.00000001
-rw-rw---- 1 root root       52 Nov 20 17:21 aria_log_control
-rw-rw---- 1 root root 50331648 Nov 20 17:21 ib_logfile0
-rw-rw---- 1 root root 50331648 Nov 20 17:21 ib_logfile1
-rw-rw---- 1 root root 12582912 Nov 20 17:21 ibdata1

My Docker Start Script:

#!/bin/bash

export SITE="/Users/xxxxxx/Documents/xxxxxx"
export HTML="${SITE}/html"
export CGI_BIN="${SITE}/cgi-bin"
export SQLDATA="${SITE}/mysql/data"
export SQLLOG="${SITE}/mysql/log"
export APACHE_CONF="${SITE}/apache/conf"
export APACHE_LOGS="${SITE}/apache/logs"

export HTTP_PORT=8080
export HTTPS_PORT=4443
export MYSQL_PORT=3600

if [ "$1" = "start" ]; then
docker run --rm -p 8080:80 -p 3600:3306 -e LOG_STDOUT=true -e LOG_STDERR=true -e LOG_LEVEL=debug \
-v ${HTML}:/var/www/html \
-v ${SQLDATA}:/var/lib/mysql \
-v ${SQLLOG}:/var/log/mysql \
-v ${APACHE_LOGS}:/var/log/httpd \
fauria/lamp
fi

if [ "$1" = "stop" ]; then
docker stop `docker ps -q`
fi
echo "docker container $1"
``

cbitterfield avatar Nov 20 '19 17:11 cbitterfield

Run docker exec ${CONTAINER_ID} mysql_install_db then docker restart ${CONTAINER_ID}

This fixed my problem.

Oisann avatar Jan 08 '20 12:01 Oisann