Skip to main content

Commands


Config Path

mysql --help | grep -B 1 etc/my.cnf
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /opt/homebrew/etc/my.cnf ~/.my.cnf

mysqldump

With DB Creation

User --database

mysqldump -hlocalhost -uroot -P3306 -pcmajor --databases foo > db-2025-05-09-17-51.sql

Docker

Pull Image

https://hub.docker.com/_/mysql/tags

docker pull mysql:8.0.36

Run Container

docker run -d \
  --name mysql-1 \
  -p 3306:3306 \
  -e MYSQL_ROOT_PASSWORD=123123 \
  -v ~/data1:/var/lib/mysql \
  mysql:8.0.36
docker run -d \
  --name mysql-foo \
  -p 3306:3306 \
  -e MYSQL_ROOT_PASSWORD=123123 \
  -v ~/mysql-foo/data:/var/lib/mysql \
  -v ~/mysql-foo/conf:/etc/mysql/conf.d \
  mysql:8.0.36

Use 127.0.0.1 instead of localhost.

mysql -h127.0.0.1 -P3306 -p123123

Create my.cnf in ~/mysql-foo/conf, it will overwrite /etc/my.cnf properties.

~/mysql-foo/conf/my.cnf
[mysqld]
enforce_gtid_consistency = ON
gtid_mode = ON