Eu não consigo iniciar o mysql depois de mover os dados para o disco rígido externo.
Minha configuração (Raspbian):
- Pasta de dados padrão do MySQL: / var / lib / mysql
- Pasta de dados do MySQL de destino: / media / exthdd / mysql_data
E foi assim que tentei realocar meus dados do mysql:
-
sudo service mysql stop
-
sudo mkdir /media/exthdd/mysql_data
-
sudo cp -adR /var/lib/mysql/ /media/exthdd/mysql_data
-
sudo chown mysql:mysql -R /media/exthdd/mysql_data
-
sudo chmod 771 -R /media/exthdd/mysql_data/
-
sudo nano /etc/mysql/my.cnf
-
datadir = /media/exthdd/mysql_data
-
sudo service mysql start
Este é o erro que recebi depois:
Job for mysql.service failed. See 'systemctl status mysql.service' and
'journalctl -xn' for details.
Em execução, journalctl -xn
recebi:
No journal files were found.
Para systemctl status mysql.service
mysql.service - LSB: Start and stop the mysql database server daemon
Loaded: loaded (/etc/init.d/mysql)
Active: failed (Result: exit-code) since Sat 2016-08-20 18:58:48 CST; 2min 4s ago
Process: 27436 ExecStop=/etc/init.d/mysql stop (code=exited, status=0/SUCCESS)
Process: 373 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE)
E o log de erros sudo cat /var/log/mysql/error.log
tinha isso:
160820 19:05:50 mysqld_safe Starting mysqld daemon with databases from
/media/exthdd/mysql_data
160820 19:05:50 [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.
160820 19:05:50 [Note] /usr/sbin/mysqld (mysqld 5.5.49-0+deb8u1)
starting as process 2403 ...
160820 19:05:50 [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.
160820 19:05:50 [Note] Plugin 'FEDERATED' is disabled. /usr/sbin/mysqld: Table 'mysql.plugin' doesn't exist
160820 19:05:50 [ERROR] Can't open the mysql.plugin table. Please run
mysql_upgrade to create it.
160820 19:05:50 InnoDB: The InnoDB memory heap is disabled
160820 19:05:50 InnoDB: Mutexes and rw_locks use GCC atomic builtins
160820 19:05:50 InnoDB: Compressed tables use zlib 1.2.8
160820 19:05:50 InnoDB: Using Linux native AIO
160820 19:05:50 InnoDB: Initializing buffer pool, size = 128.0M
160820 19:05:50 InnoDB: Completed initialization of buffer pool
160820 19:05:50 InnoDB: highest supported file format is Barracuda. InnoDB: Log scan progressed past the checkpoint lsn 49439
160820 19:05:50 InnoDB: Database was not shut down normally! InnoDB: Starting crash recovery. InnoDB: Reading tablespace information from the .ibd files... InnoDB: Restoring possible half-written data pages from the doublewrite InnoDB: buffer... InnoDB: Doing recovery: scanned up to log sequence number 1595675
160820 19:05:51 InnoDB: Starting an apply batch of log records to the database... InnoDB: Progress in percents: 45 46 47 48
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
95 96 97 98 99 InnoDB: Apply batch completed
160820 19:05:51 InnoDB:Waiting for the background threads to start
160820 19:05:52 InnoDB: 5.5.49 started; log sequence number 1595675
160820 19:05:52 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
160820 19:05:52 [Note] - '127.0.0.1' resolves to '127.0.0.1';
160820 19:05:52 [Note] Server socket created on IP: '127.0.0.1'.
160820 19:05:52 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
160820 19:05:52 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
[UPDATE]
Eu atualizei o mysql para 5.6.30-1, mas o problema persiste (embora os erros sejam diferentes agora).
Além disso, não fique confuso, eu fiz um link simbólico de / var / lib / mysql - > / media / exthdd / mysql
orangepi@OrangePI:/var/lib/mysql$ sudo service mysql start
orangepi@OrangePI:/var/lib/mysql$ sudo service mysql status
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled)
Active: inactive (dead) since Mon 2016-08-22 03:55:30 CST; 40s ago
Process: 8151 ExecStartPost=/usr/share/mysql/mysql-systemd-start post >(code=exited, status=0/SUCCESS)
Process: 8150 ExecStart=/usr/bin/mysqld_safe (code=exited, status=0/SUCCESS)
Process: 8148 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre >(code=exited, status=0/SUCCESS)
Main PID: 8150 (code=exited, status=0/SUCCESS)
Aug 22 03:55:00 OrangePI mysqld_safe[8150]: 160822 03:55:00 mysqld_safe Can't log to error log and syslog at the same time. Remove all --log-error configura...ke effect.
Aug 22 03:55:00 OrangePI mysqld_safe[8150]: 160822 03:55:00 mysqld_safe Logging to '/var/log/mysql/error.log'.
Aug 22 03:55:00 OrangePI mysqld_safe[8150]: 160822 03:55:00 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Aug 22 03:55:00 OrangePI mysqld_safe[8150]: 160822 03:55:00 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
Aug 22 03:55:30 OrangePI systemd[1]: Started MySQL Community Server.
Hint: Some lines were ellipsized, use -l to show in full.
E novamente log de erros:
orangepi@OrangePI:/var/lib/mysql$ sudo cat /var/log/mysql/error.log
160822 03:55:00 mysqld_safe Starting mysqld daemon with databases from
/var/lib/mysql
2016-08-22 03:55:00 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.
2016-08-22 03:55:00 0 [Warning] TIMESTAMP with implicit DEFAULT value
is deprecated. Please use --explicit_defaults_for_timestamp server
option (see documentation for more details).
2016-08-22 03:55:00 0 [Note] /usr/sbin/mysqld (mysqld 5.6.30-1) starting as process 8516 ...
2016-08-22 03:55:00 8516 [Warning] Can't create test file
/var/lib/mysql/OrangePI.lower-test
2016-08-22 03:55:00 8516 [Warning]
Can't create test file /var/lib/mysql/OrangePI.lower-test
/usr/sbin/mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13 -
Permission denied)
2016-08-22 03:55:00 8516 [ERROR] Aborting
2016-08-22 03:55:00 8516 [Note] Binlog end
2016-08-22 03:55:00 8516 [Note] /usr/sbin/mysqld: Shutdown complete
160822 03:55:00 mysqld_safe mysqld from pid file
/var/run/mysqld/mysqld.pid ended
Ele diz que não pode criar um arquivo de teste, mas o mysql tem todas as permissões e possui toda a pasta / arquivos mysql.