2

Recently I had to reinstall Ubuntu 16 because of a server failure (nothing to do with MySQL). I have now reinstalled Ubuntu 16, for MySQL I have uploaded my backup files from my old server to the new installation and it fails to start up. When I run

service mysql status

I get

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: activating (start-post) since Wed 2017-01-25 15:08:54 CST; 3s ago
  Process: 7872 ExecStart=/usr/bin/mysqld_safe (code=exited, status=0/SUCCESS)
  Process: 7869 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 7872 (code=exited, status=0/SUCCESS);         : 7873 (mysql-systemd-s)
   CGroup: /system.slice/mysql.service
           └─control
             ├─7873 /bin/bash /usr/share/mysql/mysql-systemd-start post
             └─8209 sleep 1

Jan 25 15:08:54 s101287 systemd[1]: Starting MySQL Community Server...
Jan 25 15:08:54 s101287 mysqld_safe[7872]: 170125 15:08:54 mysqld_safe Logging to '/var/lib/mysql/s101287.err'.
Jan 25 15:08:54 s101287 mysqld_safe[7872]: 170125 15:08:54 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

after trying to start the server. Here is the ls -la of the /var/lib/mysql directory:

total 176224
drwxr-xr-x 13 mysql mysql     4096 Jan 25 15:08 .
drwxr-xr-x 48 root  root      4096 Jan 25 13:14 ..
drwxr-xr-x  2 mysql mysql    24576 Jan 25 13:59 apache
-rwxr-xr-x  1 mysql mysql       56 Jan 25 13:05 auto.cnf
drwxr-xr-x  2 mysql mysql     4096 Jan  6 04:49 banlist
drwxr-xr-x  2 mysql mysql     4096 Jan  6 04:50 daemon
-rwxr-xr-x  1 mysql mysql        0 Jan 25 13:14 debian-5.6.flag
drwxr-xr-x  2 mysql mysql     4096 Jan 25 14:12 dnttmp
-rwxr-xr-x  1 mysql mysql 79691776 Jan 25 14:54 ibdata1
-rwxr-xr-x  1 mysql mysql 50331648 Jan 25 15:08 ib_logfile0
-rwxr-xr-x  1 mysql mysql 50331648 Jan 25 14:54 ib_logfile1
drwxr-xr-x  2 mysql mysql     4096 Jan  6 04:50 multicraft_daemon
drwxr-xr-x  2 mysql mysql     4096 Jan  6 04:50 multicraft_panel
drwxr-xr-x  2 mysql mysql     4096 Jan 25 13:05 mysql
drwxr-xr-x  2 mysql mysql     4096 Jan  6 04:51 panel
drwxr-xr-x  2 mysql mysql     4096 Jan 25 13:14 performance_schema
drwxr-xr-x  2 mysql mysql     4096 Jan  6 04:51 phpmyadmin
-rw-r-----  1 mysql mysql    15651 Jan 25 15:08 s101287.err
drwxr-xr-x  2 mysql mysql     4096 Jan 16 07:02 unturned1

I looked in the error file in the directory above and figure out that files 'ibdata1', 'ib_logfile0', and 'ib_logfile1' are the ones causing the issues. If I replace them with the original copies from installing a brand new version of MySQL it works fine. Only problem is when I try to load different tables from the databases it gives 'table doesn't exist'. After doing more digging I found this post which lead me to believe that the files which are causing issues are needed. Here is the error log when starting the server with the files from my old server:

170125 14:59:25 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2017-01-25 14:59:25 0 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
2017-01-25 14:59:25 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-01-25 14:59:25 0 [Note] /usr/sbin/mysqld (mysqld 5.6.28-0ubuntu0.15.04.1) starting as process 7489 ...
2017-01-25 14:59:25 7489 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)

2017-01-25 14:59:25 7489 [Warning] Buffered warning: Changed limits: table_open_cache: 431 (requested 2000)

2017-01-25 14:59:25 7489 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
2017-01-25 14:59:25 7489 [Note] Plugin 'FEDERATED' is disabled.
2017-01-25 14:59:25 7489 [ERROR] Function 'innodb' already exists
2017-01-25 14:59:25 7489 [Warning] Couldn't load plugin named 'innodb' with soname 'ha_innodb.so'.
2017-01-25 14:59:25 7489 [ERROR] Function 'federated' already exists
2017-01-25 14:59:25 7489 [Warning] Couldn't load plugin named 'federated' with soname 'ha_federated.so'.
2017-01-25 14:59:25 7489 [ERROR] Function 'blackhole' already exists
2017-01-25 14:59:25 7489 [Warning] Couldn't load plugin named 'blackhole' with soname 'ha_blackhole.so'.
2017-01-25 14:59:25 7489 [ERROR] Function 'archive' already exists
2017-01-25 14:59:25 7489 [Warning] Couldn't load plugin named 'archive' with soname 'ha_archive.so'.
2017-01-25 14:59:25 7489 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-01-25 14:59:25 7489 [Note] InnoDB: The InnoDB memory heap is disabled
2017-01-25 14:59:25 7489 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-01-25 14:59:25 7489 [Note] InnoDB: Memory barrier is not used
2017-01-25 14:59:25 7489 [Note] InnoDB: Compressed tables use zlib 1.2.8
2017-01-25 14:59:25 7489 [Note] InnoDB: Using Linux native AIO
2017-01-25 14:59:25 7489 [Note] InnoDB: Using CPU crc32 instructions
2017-01-25 14:59:25 7489 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-01-25 14:59:25 7489 [Note] InnoDB: Completed initialization of buffer pool
2017-01-25 14:59:25 7489 [Note] InnoDB: Highest supported file format is Barracuda.
2017-01-25 14:59:25 7489 [Note] InnoDB: 128 rollback segment(s) are active.
2017-01-25 14:59:25 7489 [Note] InnoDB: Waiting for purge to start
InnoDB: Error: tablespace id is 219 in the data dictionary
InnoDB: but in file ./mysql/innodb_index_stats.ibd it is 2!
2017-01-25 14:59:25 7f4817fff700  InnoDB: Assertion failure in thread 139947617023744 in file fil0fil.cc line 796
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.6/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
20:59:25 UTC - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed, 
something is definitely wrong and this may fail.

key_buffer_size=16777216
read_buffer_size=131072
max_used_connections=0
max_threads=151
thread_count=0
connection_count=0
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 76296 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0 thread_stack 0x30000
/usr/sbin/mysqld(my_print_stacktrace+0x3b)[0x8e7c3b]
/usr/sbin/mysqld(handle_fatal_signal+0x36a)[0x646c0a]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x10d10)[0x7f4834132d10]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x37)[0x7f4833560267]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f4833561eca]
/usr/sbin/mysqld[0xa5f211]
/usr/sbin/mysqld[0xa5f3ce]
/usr/sbin/mysqld[0xa6932b]
/usr/sbin/mysqld[0xa31041]
/usr/sbin/mysqld[0xa190ac]
/usr/sbin/mysqld[0x9feed5]
/usr/sbin/mysqld[0x9a5b80]
/usr/sbin/mysqld[0x9a2807]
/usr/sbin/mysqld[0x9a42a7]
/usr/sbin/mysqld[0x972845]
/usr/sbin/mysqld[0x9c9405]
/usr/sbin/mysqld[0x9bc6c5]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76aa)[0x7f48341296aa]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7f4833631eed]
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
170125 14:59:25 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

These two lines peek my interest:

InnoDB: Error: tablespace id is 219 in the data dictionary
InnoDB: but in file ./mysql/innodb_index_stats.ibd it is 2!

if the problem were to lie in the tablespace and another file's ids not matching, would it cause this problem or is my theory going into the deep end? If I'm not able to change the ids in one of the files, how would I successfully use the files that are causing problems, as I've stated, I need them for half my tables to work.

8
  • how did you do a backup? how did you reinstantiate your files. did you do a db backup? did you use mysql to do a backup? lots of information here, while lacking a clear explination of the problem and what kind of solution youre expecting.
    – user383919
    Jan 25 '17 at 21:39
  • I literally just copied the files from /var/lib/mysql from my old server to my new one.
    – user608659
    Jan 25 '17 at 21:45
  • did you backup and copy /etc/mysql too? you need your configuration files as well.
    – user383919
    Jan 26 '17 at 1:23
  • also, your output states you may be experiencing software incompatibility and data corruption. 16.04 uses a updated version of mysql as well. i would try and install the packages you were previously using and see if it works. easy way to test is set up a VM w/ your last environment and see if the backup works. if it does work, you can tweak your new environ as neccessary. if it doesnt, my condolences
    – user383919
    Jan 26 '17 at 1:34
  • my best guess is that your database isnt compatible w/ the new one and that most likely it isnt corrupted. follow the links in your error output and diagnose it to narrow the issue down.
    – user383919
    Jan 26 '17 at 1:40
2

After failing to get my MySQL server to work, I realized I wasn't copying the entire /var/lib/mysql over to the new server. After stopping the MySQL server, deleting the installation-made /var/lib/mysql I copied my old file over and successfully started the server. Mixing the files between the two copies does not work! Thanks to all those who tried to help!

Your Answer

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