I ended up deleting the tc.log file in /var/lib/mysql. When I started mysql again, it created a new tc.log and started up.
sudo rm -f /var/lib/mysql/tc.log
It sounds like you're new to Docker. You may want to spend some time reading through documentation and examples to get a better feel for how things work.
First, simply installing software doesn't necessarily make it run, and that is certainly the case with CentOS and other Red Hat variants. On a bare metal host, you would simply run systemctl start mariadb
to start it, but this only works because on a regular system, the /sbin/init
component of systemd is started as part of the boot process.
Inside a docker container, nothing is running by default. For example, if you were to run ps -fe
on your host, you would probably see hundreds of running processes.
If you were to run:
docker run centos ps -fe
You would see:
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 11:12 ? 00:00:00 ps -fe
Because of this, you can't start services using the normal mechanism. You will instead need to (a) start the service manually and (b) ensure that you have started it such that it will stay in the foreground (because a Docker container exits when the foreground process exits or puts itself into the background).
If you take a look at the official mariadb image, you will see that it ultimately just calls mysqld
to start the service.
It sounds like you want to start mariadb inside a container and then try interacting it from within the same container. While this isn't the normal way of working with docker, you could...
$ docker run -it centos bash
[root@c1d6adf5c8bb /]# yum -y install mariadb-server
[root@c1d6adf5c8bb /]# /usr/libexec/mariadb-prepare-db-dir mariadb.service
[root@c1d6adf5c8bb /]# /usr/bin/mysqld_safe --basedir=/usr &
[root@c1d6adf5c8bb /]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 1
Server version: 5.5.52-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
More typically, you would use a Dockerfile
to build a mariadb image (or just use the official one), start it, and then use mysql
on your host or in another container to interact with that mariadb instance.
Best Answer
Is this still relevant?
You haven't mentioned what your host is (I take it it is Windows). From what you mentioned, I assume also, you used mapping to host system (full path) and not. named (docker managed) volumes. In addition it would be important to know -- if your host is indeed windows -- how you installed docker (docker desktop in hyper-v, virualbox/vmware)
I go by what I got and guess to start:
The constallation Docker on Windows and host volumes -- especially for databases -- is known to cause problems (see e.g. https://github.com/docker-library/mariadb/issues/152 or https://stackoverflow.com/questions/41343972/docker-volumes-mariadb-windows)
If my guesses are right, then two things strike me as strange though: 1. How could this mariadb docker ever have worked and 2. where do those old database-files come from? Is it possible these are an old artefact from a different (possibly local) installation?
You imply that possibly shutting down the mariadb container some time in the past (SIGTERM) lost the connection to the volume and on restart continued to work but that does not seem to match up with other evidence you provide (it obviously did work well up until your last (first?) restart of the container).
Could something have changed with the access-rights to the files or the folder on the host (although that would speak more for a Linux host)? See https://medium.com/@nielssj/docker-volumes-and-file-system-permissions-772c1aee23ca for further information. Again, this does not explani why mariadb did still run up until the problem you noticed.
Closing (again assuming this is Docker on Windows) your problem might be much smaller now (speaking after Windows 10 2004 was released) using Docker in WSL 2 because you can use named (docker managed) volumes and still easily access these as linux folders in wsl 2 are directly mounted in Windows.
Sorry, this is probably not the answer you expected. If you clarify your situation I (or somebody else) might be able to be more specific.