My SSD got corrupted. I made a clone of it on an HDD and I have access to all original files from /var/lib/mysql/that_database.

I want to import that_database back, but I can't.

What I've tried already

Copying the database files themselves

I tried to copy the raw files, and it didn't work: show tables works, but queries end with that_database.TableName does not exist.

Copying the entire /var/lib/mysql directory

One of the another_database and sys databases are corrupted. After the files were copied, I tried to restart the server and it cannot start.

$ sudo service mysql start
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
$ systemctl status mysql.service
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2018-04-23 13:50:01 EEST; 2s ago
  Process: 23954 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
  Process: 23945 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 22245 (code=exited, status=0/SUCCESS)

apr 23 13:50:01 notebook systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
apr 23 13:50:01 notebook systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
apr 23 13:50:01 notebook systemd[1]: Stopped MySQL Community Server.
apr 23 13:50:01 notebook systemd[1]: mysql.service: Start request repeated too quickly.
apr 23 13:50:01 notebook systemd[1]: mysql.service: Failed with result 'exit-code'.
apr 23 13:50:01 notebook systemd[1]: Failed to start MySQL Community Server.

How can I recover this database?

  • If you for instance use InnoDB, without the innodb_file_per_table option option, rather than MyISAM as the storage engine the data may be stored in the system tablespace and not in the files in /var/lib/mysql/that_database – HBruijn Apr 23 '18 at 10:32
  • @HBruijn Yes, I think I use InnoDB. I have all those files, except one database is corrupted. Should I just copy all the files and delete that database which is corrupted? – Ionică Bizău Apr 23 '18 at 10:46
  • I updated my post. – Ionică Bizău Apr 23 '18 at 10:52
  • are you using the same my.cnf setting as earlier, i would recommend first take backup of entire database folder and keep it safe then work on restore, post your mysql logs – Vijay Muddu Apr 23 '18 at 12:51
  • I already have a clone of the entire partition. I can try to put the same my.cnf if it helps. What logs are you interested about? – Ionică Bizău Apr 23 '18 at 12:58

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.