简体   繁体   中英

How to restore mysql database backup from terminal?

I make daily backups by running the following cronjob:

mysqldump --user root --password=xxxx databasename > /home/ec2-user/backup/databasebackup_$today

How would I go about to simply restore from a backup, completely overwriting whatever there might be?

Did you try with...

mysql --user=root --password=xxxx --database=databasename < /home/ec2-user/backup/databasebackup_$today

Hope it helps

Another way

mysql -u root -p databasename < /home/ec2-user/backup/databasebackup_$today

You will be prompt to enter password. Supposing you are not planning to cron restore procedure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM