I recently had an error with my SD card inside my RaspberryPi4. (I'm very inexperienced with databases as well.) So this means that I have to restore my database. What I did was copying all the files to the folder:


I used chroot to set the owner to mysql. However, now the serverice mysql does not start and gives an error on startup.

mysql.serviceJob for mariadb.service failed because the control process exited with error code. 
See "systemctl status mariadb.service" and "journalctl -xe" for details.                                                              

I checked journalctl -xe and it returned the following:

The job identifier is 799.
Jan 12 22:10:01 raspberrypi mysqld[1259]: 2020-01-12 22:10:01 0 [Note] /usr/sbin/mysqld (mysqld 10.3.17-MariaDB-0+deb10u1) starting as process
Jan 12 22:10:02 raspberrypi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- An ExecStart= process belonging to unit mariadb.service has exited.
-- The process' exit code is 'exited' and its exit status is 1.
Jan 12 22:10:02 raspberrypi systemd[1]: mariadb.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- The unit mariadb.service has entered the 'failed' state with result 'exit-code'.
Jan 12 22:10:02 raspberrypi systemd[1]: Failed to start MariaDB 10.3.17 database server.
-- Subject: A start job for unit mariadb.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- A start job for unit mariadb.service has finished with a failure.
-- The job identifier is 799 and the job result is failed.

So currently I'm hesitating whether I should reinstall mysql, or that I need to do a couple of small things to get everything working.

The folder structure is as follows (mysql folder):mysql folder

And one of the important DBs looks as follows (Freelobot): freelobot folder

Checking error.log yields

2020-01-13  1:12:38 0 [Note] InnoDB: Using Linux native AIO
2020-01-13  1:12:38 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-01-13  1:12:38 0 [Note] InnoDB: Uses event mutexes
2020-01-13  1:12:38 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-01-13  1:12:38 0 [Note] InnoDB: Number of pools: 1
2020-01-13  1:12:38 0 [Note] InnoDB: Using generic crc32 instructions
2020-01-13  1:12:38 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-01-13  1:12:38 0 [Note] InnoDB: Completed initialization of buffer pool
2020-01-13  1:12:38 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-01-13  1:12:38 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=36121288
2020-01-13  1:12:38 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2020-01-13  1:12:38 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2020-01-13  1:12:38 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-01-13  1:12:38 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-01-13  1:12:38 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-01-13  1:12:38 0 [Note] InnoDB: 10.3.17 started; log sequence number 36121297; transaction id 198032
2020-01-13  1:12:38 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2020-01-13  1:12:38 0 [Note] Plugin 'FEEDBACK' is disabled.
2020-01-13  1:12:38 0 [Note] Recovering after a crash using tc.log
2020-01-13  1:12:38 0 [Note] Starting crash recovery...
2020-01-13  1:12:38 0 [Note] Crash recovery finished.
2020-01-13  1:12:38 0 [Note] InnoDB: Buffer pool(s) load completed at 200113  1:12:38
2020-01-13  1:12:38 0 [Note] Server socket created on IP: ''.
2020-01-13  1:12:38 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist in engine
  • Please post relevant part of /var/log/mysql/error.log - maybe it's just a matter of file ownership. – Eugen Rieck Jan 12 at 23:53
  • @EugenRieck I've edited my post – Kevin Laemers Jan 13 at 1:10
  • The error is around the mysql.user table. Can you show the directory listing for that folder. What mysql version was the backup that is being restored from? – danblack Jan 13 at 1:27
  • btw the restoration should be all of the previous files, mixing and matching selective files cannot work. – danblack Jan 13 at 1:46
  • Ah, did you forget to also copy the /etc/mysql folder? – Eugen Rieck Jan 13 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.