2015-02-14 11 views
5

MySQL (Percona 5.6) sẽ không bắt đầu.Lỗi nghiêm trọng về MySQL: Không thể mở và khóa bảng đặc quyền: Định dạng tệp không chính xác 'người dùng'

Lỗi này đã xảy ra với tôi nhiều lần. Mỗi lần, tôi phải gỡ bỏ các thư mục dữ liệu MySQL và cài đặt lại MySQL.

Có cách nào khác để sửa lỗi MySQL không? (Cụ thể một trong đó dữ liệu không bị thổi bay?)

/var/log/mysql/error.log

150214 16:36:39 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 
2015-02-14 16:36:40 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. 
2015-02-14 16:36:40 0 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release. 
2015-02-14 16:36:40 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 
2015-02-14 16:36:40 1018 [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. 
2015-02-14 16:36:40 1018 [Note] Plugin 'FEDERATED' is disabled. 
/usr/sbin/mysqld: Incorrect file format 'plugin' 
2015-02-14 16:36:40 1018 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. 
2015-02-14 16:36:40 1018 [Note] InnoDB: Using atomics to ref count buffer pool pages 
2015-02-14 16:36:40 1018 [Note] InnoDB: The InnoDB memory heap is disabled 
2015-02-14 16:36:40 1018 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 
2015-02-14 16:36:40 1018 [Note] InnoDB: Memory barrier is not used 
2015-02-14 16:36:40 1018 [Note] InnoDB: Compressed tables use zlib 1.2.8 
2015-02-14 16:36:40 1018 [Note] InnoDB: Using Linux native AIO 
2015-02-14 16:36:40 1018 [Note] InnoDB: Using CPU crc32 instructions 
2015-02-14 16:36:40 1018 [Note] InnoDB: Initializing buffer pool, size = 256.0M 
2015-02-14 16:36:40 1018 [Note] InnoDB: Completed initialization of buffer pool 
2015-02-14 16:36:40 1018 [Note] InnoDB: Highest supported file format is Barracuda. 
2015-02-14 16:36:40 1018 [Note] InnoDB: The log sequence numbers 714340126 and 714340126 in ibdata files do not match the log sequence number 716513090 in the ib_logfiles! 
2015-02-14 16:36:40 1018 [Note] InnoDB: Database was not shutdown normally! 
2015-02-14 16:36:40 1018 [Note] InnoDB: Starting crash recovery. 
2015-02-14 16:36:40 1018 [Note] InnoDB: Reading tablespace information from the .ibd files... 
2015-02-14 16:36:40 1018 [Note] InnoDB: Restoring possible half-written data pages 
2015-02-14 16:36:40 1018 [Note] InnoDB: from the doublewrite buffer... 
InnoDB: Last MySQL binlog file position 0 292596, file name binlog.000056 
2015-02-14 16:36:40 1018 [Note] InnoDB: 128 rollback segment(s) are active. 
2015-02-14 16:36:40 1018 [Note] InnoDB: Waiting for purge to start 
2015-02-14 16:36:40 1018 [Note] InnoDB: Percona XtraDB (http://www.percona.com) 5.6.21-70.1 started; log sequence number 716513090 
2015-02-14 16:36:40 1018 [Note] Recovering after a crash using binlog 
2015-02-14 16:36:40 1018 [Note] Starting crash recovery... 
2015-02-14 16:36:40 1018 [Note] Crash recovery finished. 
2015-02-14 16:36:40 1018 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work. 
2015-02-14 16:36:40 1018 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work. 
2015-02-14 16:36:40 1018 [Note] Server hostname (bind-address): '*'; port: 3306 
2015-02-14 16:36:40 1018 [Note] IPv6 is available. 
2015-02-14 16:36:40 1018 [Note] - '::' resolves to '::'; 
2015-02-14 16:36:40 1018 [Note] Server socket created on IP: '::'. 
2015-02-14 16:36:40 1018 [ERROR] Fatal error: Can't open and lock privilege tables: Incorrect file format 'user' 
150214 16:36:40 mysqld_safe mysqld from pid file /tmp/mysqld.pid ended 
+1

bạn có thể thử khởi chạy 'mysql_upgrade' (như được đề xuất trong nhật ký); hoặc cuối cùng 'mysql_install_db' –

+0

Bạn có thể có một cái gì đó rối tung với gói của bạn ... Bạn có cơ hội một cái gì đó mà đưa trở lại bình thường MySQL (vs percona?) Và sau đó trở lại percona? Khi bạn làm cho nó chạy sao lưu cơ sở dữ liệu "mysql" của bạn, bạn sẽ có thể đặt nó trở lại nếu đó là trường hợp. – ROunofF

Trả lời

11

tôi quản lý để giải quyết vấn đề này với answer from ruby.b

You'll have to repair your host table. To do this, issue the following command to start your server bypassing the privilege system

Trong một thiết bị đầu cuối, hãy chạy

$ sudo mysqld --skip-grant-tables 

Mở một thiết bị khác thiết bị đầu cuối và thực hiện các lệnh

$ mysql 
mysql> use mysql 
mysql> repair table host use_frm; 
mysql> exit 

Và khởi động lại dịch vụ mysql

$ sudo service mysql restart 
+0

cảm ơn bạn rất nhiều. trong trường hợp của tôi tôi đã phải sửa chữa bảng người dùng thay vì bảng máy chủ vì vậy tôi đã làm: sửa chữa bảng người dùng use_frm; thay vào đó và nó đã hoạt động! – Rejinderi

3

Nhờ John đưa tôi đi đúng hướng, tôi đã có một vài hoops khác để nhảy qua trên hệ thống của tôi. Hy vọng điều này sẽ giúp một ai đó.

Đây là bảng đặc quyền bị hỏng. Có thể do nâng cấp hoặc mất điện. Hệ thống của tôi OpenSUSE 13.2, MySQL 5.6. Đơn giản cài đặt lại không sửa chữa, phải xóa tất cả dấu vết của MySQL trước khi cài đặt lại HOẶC ...

Đóng cửa tất cả các trường hợp của MySQL

$ systemctl stop mysql.service 
$ pkill -9 mysqld 

máy chủ Bắt đầu bỏ qua hệ thống đặc quyền

$ sudo mysqld_safe --user=root --skip-grant-tables 
cụ

Bắt đầu MySQL dòng lệnh

$ mysql 

Nếu bạn nhận được

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) 

mysqld_safe đang chạy với ổ cắm của nó ở một nơi khác. Tìm nó với.

$ sudo find/-type s 

Mine là trong/var/run/mysql/ Chỉnh sửa dòng ổ cắm trong my.cnf, làm cho một lưu ý của thiết lập ổ cắm hiện tại của bạn. Dòng của tôi đã trở thành

socket=/var/run/mysql/mysql.sock 

Quay lại 'Đóng tất cả các phiên bản của MySQL' (đầu các hướng dẫn này). Theo dõi chúng thông qua 'Bắt ​​đầu công cụ dòng lệnh MySQL'. Hy vọng rằng bạn có thể mở mysql thành công. Từ dòng lệnh mysql.

mysql> use mysql 
mysql> repair table user use_frm; 
mysql> exit 

Đóng cửa tất cả các trường hợp của MySQL

$ systemctl stop mysql.service 
$ pkill -9 mysqld 

Re-edit my.cnf, trả lại dòng socket để thiết lập ban đầu của nó.

Tôi phải đặt lại quyền trên 2 tệp trong thư mục dữ liệu mysql của mình.

$ chown mysql:mysql server2.err 
$ chown mysql:mysql server2.pid 

Khởi động máy chủ MySQL

$ systemctl start mysql.service 

sau đó tôi đã nhận lỗi ban đầu cùng với một bảng (db)

[ERROR] Fatal error: Can't open and lock privilege tables: Incorrect file format 'db' 

Và đã phải lặp lại các thao tác trên nhiều lần thay đổi ' sửa chữa 'lệnh cho đến khi tất cả các bảng đặc quyền đã được cố định.

mysql> repair table db use_frm; 
+2

'mysqld_safe --user = root --skip-grant-tables' đã cứu mạng tôi !! – russellhoff

Các vấn đề liên quan