Is there some way to grant all privileges to root via Dockerfile ou docker-compose.yml?
I'm trying to boot up a mysql:latest image like this:
docker-compose.yml
version: "3.9"
services:
mysql_database:
container_name: mysql_test_server
restart: always
build: .
image: mysql:latest
command: --default-authentication-plugin=mysql_native_password
ports:
- 3306:3306
volumes:
- ./data:/var/lib/mysql
- ./config:/etc/mysql/conf.d
environment:
MYSQL_ROOT_PASSWORD: root
dockerfile (the build: . on .yml)
FROM mysql:latest
RUN mysql -u root -proot -h localhost -p 3306
RUN grant all privileges on *.* to 'root'@'%' identified by 'root';
RUN flush all privileges;
RUN exit;
EXPOSE 3306
TLDR; I just want to grant privileges for remote connections (SQLYog, DBeaver, etc) automatically... if docker-compose up, run this command so I don't need to do manually, like docker exet -it mysql_test_server mysql -u root ...
I awalys get this:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
question from:
https://stackoverflow.com/questions/65834162/grant-privileges-to-root-via-dockerfile 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…