Read more

Howto transfer a single mysql table between several deployment stages

Deleted user #6
September 27, 2012Software engineer

Example task: Multiply the table holidays between several stages.

  1. Open two terminals:

    shell-for stage_1
    shell-for stage_2
    
  2. Get the stage1 and stage2 MySQL credentials:

    cat /opt/www/the_stage.host.tld/current/config/database.yml
    cat config/database.yml # should do it
    
  3. Dump the table to a path reachable by the stage2 user (e.g. home):

    mysqldump -h mysql1 -u stage_1_user -p stage_1_database table_name > ~/table_name_dump.mysql # Select certain records using --where "some_id > 666"
    

    (-h stands for hostname and it is in deed 'mysql1')

  4. Import the dump:

    mysql -h mysql1 -u stage_2_user -p stage_2_database < /home/stage_1_user/table_name_dump.mysql # attention to stage1 and stage2
    
Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

Note that importing a table overwrites an existing table. There won't be a magic merge.

Posted to makandra dev (2012-09-27 12:13)