Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Oct 2016
    Posts
    43
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Single command to reset a database

    I have a local and an online version of a MySQL database.
    I want to write a shell script that syncs the two versions by
    replacing the local version with the current state of the online version.

    I already know how to retrieve the current state of the online version,
    by doing mysqldump -uonline_usr -ponline_passwd online_db > backup.sql, and I also
    know how to resend the backup to my computer using scp.

    But I don't know about the rest (resetting the local db to the value defined in
    backup.sql), as of now I only know how to do it in phpMyAdmin.

    Any help appreciated.

  2. #2
    New Coder
    Join Date
    Oct 2016
    Posts
    43
    Thanks
    9
    Thanked 0 Times in 0 Posts
    There is a nice script for the "empty database" part at https://www.cyberciti.biz/faq/how-do...ysql-database/.
    The rest is simply a non-interactive use of the mysql command, as explained in the oupt of `man mysql`


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •