Restoring a mysql backup

5,863

This is solution restore single MySQL Database from that backups.

Before you restore a database, you must create an empty database on the target machine and restore the database using msyql command. For example the following command will restore the restore_backup.sql file to the rsyslog database.

# mysql -h localhost -u root -pazzazy(this is pass root you setup) restore_backup < restore_backup.sql

If you want to restore a database that already exist on targeted machine, then you will need to use the mysqlimport command.

# mysqlimport -u root -pazzazy(this is pass root you setup) restore_backup < restore_backup.sql

In the same way you can also restore database tables, structures and data.

In Case with file sql.gz you can restore with command:

gunzip < test.sql.gz | mysql -u [uname] -p[pass] [dbname]

And Please you can read Backup and Restore Database .gz

Share:
5,863
Mohamed Azzazy
Author by

Mohamed Azzazy

Updated on September 18, 2022

Comments

  • Mohamed Azzazy
    Mohamed Azzazy over 1 year

    Hello i am using a vps running ubuntu 1604 and i have done this Automatic backup of mysql on ubuntu but i want now to restore that backup Thanks in advance

    • George Udosen
      George Udosen almost 7 years
      Are you using phpmyadminconsole?
    • Mohamed Azzazy
      Mohamed Azzazy almost 7 years
      disabled it but i can enable.
    • George Udosen
      George Udosen almost 7 years
      How were you planning on restoring database from command line, I believe the console is better
    • EODCraft Staff
      EODCraft Staff almost 7 years
  • Rinzwind
    Rinzwind almost 7 years
    Unsafe. That will echo the password to the processlist.
  • Tannetto
    Tannetto almost 7 years
    Yes, with command maybe not show password and remove option` -pazzazy`. So when restore database you can login password when run command.
  • Mohamed Azzazy
    Mohamed Azzazy almost 7 years
    my database format is sql.gz i dont think that this will work.
  • Tannetto
    Tannetto almost 7 years
    With database format is sql.gz you can use backup all database sql with command gzip. I'm update command backup and restore with sql.gz.