Question

How to restore a website if data is corrupted

So, my site got messed up due to DDoS attack due to which I had to uninstall and install MYSQL again. I found that it isn’t wordpress database and the backup which I have is corrupted one and another backup which I have is from March’22. But now my backup is in .sql while it needs .ibd format so I can’t transfer these backup directly from SFTP.

I tried doing it from CLI using following statement:

mysql -u your_database_user -p wordpress -h localhost < your_backup_file.sql

and this was the output:

$ mysql -u root -p wordpress -h localhost < db.sql
-bash: db.sql: No such file or directory

$ mysql -u root -p wordpress < db.sql
-bash: db.sql: No such file or directory

$ mysql -u root -p wordpress -h localhost < /var/lib/mysql/db.sql
Enter password: 

So, after entering the password isn’t showing any output. I’m using droplet’s root password. Or do I need to use the db_password from wp-config file?

I also did this in a new droplet but I’m getting same error for the transferring database.

In 1 case I the data was transferred but I got this on homepage

There has been a critical error on this website.

Please help me out

Thanks!


Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

alexdo
Site Moderator
Site Moderator badge
May 14, 2022

Hello there,

You’ll need to use the password for the database which is also stored within the wp-config.php file indeed.

  1. mysql -u username -p new_database < data-dump.sql

**username ** is the username you can log in to the database with newdatabase is the name of the freshly created database data-dump.sql is the data dump file to be imported, located in the current directory

If the command runs successfully, it won’t produce any output. If any errors occur during the process, MySQL will print them to the terminal instead. To check if the import was successful, log in to the MySQL shell and inspect the data. Select the new database with USE new_database and then use SHOW TABLES; or a similar command to look at some of the data.

You can also check our tutorial on How To Import and Export Databases in MySQL or MariaDB

https://www.digitalocean.com/community/tutorials/how-to-import-and-export-databases-in-mysql-or-mariadb

Hope that this helps!