LoginSignup
0
0

More than 3 years have passed since last update.

mysqldumpでデータベースを指定してdumpする

Posted at

dumpコマンド

  • dbname = test
mysqldump -uroot -p -h<hostname> -B <dbname> > test.sql

dumpfileの中身

  • データベースが指定される
  20 --
  21 -- GTID state at the beginning of the backup 
  22 --
  23 
  24 SET @@GLOBAL.GTID_PURGED='';
  25 
  26 --
  27 -- Current Database: `test`
  28 --
  29 
  30 CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET utf8 */;
  31 
  32 USE `test`;
  33 
  34 --

あ、

  • docker-composeで初期データを入れる場合、データベースの指定がないと流し込めないので、こちらのやり方でdumpを取得する必要があるみたいです
  1 db:                                                                                           
  2   image: mysql:latest
  3   volumes:
  4     - ./initdb.d:/docker-entrypoint-initdb.d
  5   environment:
  6     - MYSQL_ROOT_PASSWORD=root
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0