mysqldockermysqlbinlog

MySQL data directory stays default with -v flag in docker image


I am trying to start MySQL using docker image, I wanted to have a look at the binlog files, however I couldn't find them in /var/lib/mysql. From a few stackoverflow and Google reads, potential reason could be that mysql doesn't have permissions to write in /var/lib/mysql.
So I tried providing a different path using -v flag while starting the docker using the command docker run -it --rm --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=debezium -e MYSQL_USER=mysqluser -e MYSQL_PASSWORD=mysqlpw -v /home/username/mysql debezium/example-mysql:1.1
However, even after this, datadir variable in client still remains /var/lib/mysql. Can someone help me in this?
Using docker run -it --rm --name mysqlterm --link mysql --rm mysql:5.7 sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD" to start the MySQL client.


Solution

  • You are running client on different container and expect yo find logs there? if you want see log files, you should run docker exec mysql bash, sometimes bash is not available, then use sh.