Recentemente eu tive que reinstalar o Ubuntu 16 por causa de uma falha no servidor (nada a ver com o MySQL). Agora eu reinstalei o Ubuntu 16, para o MySQL eu carreguei meus arquivos de backup do meu servidor antigo para a nova instalação e ele não inicializa. Quando eu corro
service mysql status
Eu obtenho
● 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
depois de tentar iniciar o servidor.
Aqui está o ls -la do diretório / var / lib / mysql:
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
Eu olhei no arquivo de erro no diretório acima e descobri que os arquivos 'ibdata1', 'ib_logfile0' e 'ib_logfile1' são os que causam os problemas. Se eu substituí-los com as cópias originais de instalar uma nova versão do MySQL, ele funciona bem. O único problema é quando tento carregar tabelas diferentes dos bancos de dados que a tabela 'não existe'. Depois de fazer mais pesquisas, encontrei este post o que me leva a acreditar que os arquivos que estão causando problemas são necessários. Aqui está o log de erros ao iniciar o servidor com os arquivos do meu servidor antigo:
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
Essas duas linhas me interessam:
InnoDB: Error: tablespace id is 219 in the data dictionary
InnoDB: but in file ./mysql/innodb_index_stats.ibd it is 2!
se o problema estivesse no espaço de tabelas e os ids de outro arquivo não correspondessem, isso causaria esse problema ou a minha teoria iria para o fundo do poço? Se não for possível alterar os IDs em um dos arquivos, como utilizarei com êxito os arquivos que estão causando problemas, conforme afirmei, preciso deles para que metade das minhas tabelas funcionem.