Tôi có một thùng chứa docker chạy mysql-5.5 với khối lượng dữ liệu máy chủ. Tôi đang nâng cấp vùng chứa của mình lên mysql-5.6. Tôi đang bắt đầu một vùng chứa mới với cùng khối lượng máy chủ. MySQL đã bị rơi trong vùng chứa do sự cố của bảng mysql.user
.Làm cách nào để di chuyển thư mục dữ liệu mysql trong vùng chứa docker?
[ERROR] Fatal error: Can't open and lock privilege tables:
Incorrect key file for table 'user'; try to repair it
160523 12:04:13 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
Tôi đã thử các sau đây để khắc phục điều đó:
[email protected]# mysqld --skip-grant-tables;
[email protected]# mysql -uroot -ppassword
mysql> repair table user USE_FRM;
+------------+--------+----------+--------------------------------------------------+
| Table | Op | Msg_type | Msg_text |
+------------+--------+----------+--------------------------------------------------+
| mysql.user | repair | info | Key 1 - Found wrong stored record at 0 |
| mysql.user | repair | info | Found block that points outside data file at 184 |
| mysql.user | repair | info | Found block that points outside data file at 292 |
| mysql.user | repair | info | Found block that points outside data file at 296 |
| mysql.user | repair | info | Found block that points outside data file at 300 |
| mysql.user | repair | info | Found block that points outside data file at 304 |
| mysql.user | repair | info | Found block that points outside data file at 308 |
| mysql.user | repair | info | Found block that points outside data file at 312 |
| mysql.user | repair | info | Found block that points outside data file at 316 |
| mysql.user | repair | info | Found block that points outside data file at 340 |
| mysql.user | repair | info | Found block that points outside data file at 392 |
| mysql.user | repair | info | Found block that points outside data file at 396 |
| mysql.user | repair | info | Found block that points outside data file at 400 |
| mysql.user | repair | info | Found block that points outside data file at 404 |
| mysql.user | repair | info | Found block that points outside data file at 408 |
| mysql.user | repair | info | Found block that points outside data file at 412 |
| mysql.user | repair | info | Found block that points outside data file at 416 |
| mysql.user | repair | info | Found block that points outside data file at 420 |
| mysql.user | repair | info | Found block that points outside data file at 448 |
| mysql.user | repair | info | Found block that points outside data file at 452 |
| mysql.user | repair | info | Found block that points outside data file at 456 |
| mysql.user | repair | info | Found block that points outside data file at 460 |
| mysql.user | repair | info | Found block that points outside data file at 464 |
| mysql.user | repair | info | Found block that points outside data file at 468 |
| mysql.user | repair | info | Found block that points outside data file at 472 |
| mysql.user | repair | info | Found block that points outside data file at 500 |
| mysql.user | repair | info | Found block that points outside data file at 504 |
| mysql.user | repair | info | Found block that points outside data file at 508 |
| mysql.user | repair | info | Found block that points outside data file at 512 |
| mysql.user | repair | info | Found block that points outside data file at 516 |
| mysql.user | repair | info | Found block that points outside data file at 520 |
| mysql.user | repair | info | Found block that points outside data file at 524 |
| mysql.user | repair | info | Found block that points outside data file at 528 |
| mysql.user | repair | info | Found block that points outside data file at 556 |
| mysql.user | repair | info | Found block that points outside data file at 560 |
| mysql.user | repair | info | Found block that points outside data file at 564 |
| mysql.user | repair | info | Found block that points outside data file at 568 |
| mysql.user | repair | info | Found block that points outside data file at 572 |
| mysql.user | repair | info | Found block that points outside data file at 576 |
| mysql.user | repair | info | Found block that points outside data file at 580 |
| mysql.user | repair | info | Found block that points outside data file at 604 |
| mysql.user | repair | info | Found block that points outside data file at 608 |
| mysql.user | repair | info | Found block that points outside data file at 612 |
| mysql.user | repair | info | Found block that points outside data file at 616 |
| mysql.user | repair | info | Found block that points outside data file at 620 |
| mysql.user | repair | info | Found block that points outside data file at 624 |
| mysql.user | repair | info | Found block that points outside data file at 628 |
| mysql.user | repair | info | Found block that points outside data file at 632 |
| mysql.user | repair | status | OK |
+------------+--------+----------+--------------------------------------------------+
49 rows in set (0.00 sec)
Lỗi: tôi không thể đăng nhập vào máy chủ mysql sử dụng username/mật khẩu. Bất kỳ ý tưởng về làm thế nào tôi nên nâng cấp dữ liệu mysql của tôi?
[email protected]# mysql -uroot -ppassword
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.30-0ubuntu0.14.04.1 (Ubuntu)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> exit;
Bye
[email protected]# ps -ef|grep mysql
root 1509 31492 0 12:15 ? 00:00:00 grep --color=auto mysql
mysql 31281 4823 0 12:06 ? 00:00:01 mysqld --skip-grant-tables --user=mysql
[email protected]# kill -9 31281
[email protected]# ps -ef|grep mysql
root 1698 31492 0 12:16 ? 00:00:00 grep --color=auto mysql
[email protected]# mysqld_safe &
[1] 1700
[email protected]# 160523 12:16:34 mysqld_safe Can't log to error log and syslog at the same time. Remove all --log-error configuration options for --syslog to take effect.
160523 12:16:34 mysqld_safe Logging to '/var/log/mysql/error.log'.
160523 12:16:34 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
^C
[email protected]# mysql -uroot -ppassword
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[email protected]#
tham khảo:
MySQL Fatal error: Can't open and lock privilege tables: Incorrect file format 'user' https://bugs.mysql.com/bug.php?id=68385
Điều gì sẽ xảy ra sau khi bạn sử dụng lệnh: 'kill -9 31281', nó vẫn nằm trong bộ lưu trữ docker hoặc đăng xuất vùng chứa? –
Vùng chứa của tôi vẫn còn hoạt động, vì mysql không phải là 'CMD' của tôi. Tôi đang chạy các quá trình khác như tomcat bằng cách sử dụng giám sát. vì vậy CMD của tôi là một kịch bản mà cấu hình và bắt đầu mysql và sau đó giám sát sẽ chăm sóc. Tôi nghĩ rằng nó không phải là một vấn đề với container docker. Như đã đề cập trong các tài liệu tham khảo, nó có thể được tái sản xuất mà không có docker. – Gangaraju