Score:1

How to access /var/lib/mysql folder in ubuntu

br flag

I'm creating a docker container with volume but I can't access the container directory, does anyone know how to solve this?

The command used is this:

docker run --name Mysql -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -v mysql-data:/var/lib/mysql mysql:latest
in flag
Will any other MySQL installation use the same directory? Or will just this one Docker container use it?
Rafael Souza avatar
br flag
only this docker container will use
Score:1
in flag

The issue has to do with directory permissions. The /var/lib/mysql/ directory is owned by mysql. If only a single Docker container will use this directory, you can change its ownership to the same account that operates Docker.

For example:

sudo chown -R rafael:rafael /var/lib/mysql

Doing this will allow the Docker container to access all of the files that currently exist in that given directory, which may be useful if you are trying to ensure MySQL is always a specific version while keeping the core OS up to date with security patches.

Rafael Souza avatar
br flag
Setting like this with my directory does not store the data? -v ~/volume/mysql/data:/data/db thank you.
in flag
That will use a directory different from `/var/lib/mysql`, but will work just as fine if you are happy with that location. So long as the permissions are correct, the data can be stored in any directory on the host.
Score:0
br flag

[SOLVED]

docker run --name Mysql -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -v ~/volume/mysql/data:/var/lib/mysql mysql:latest

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.