> 数据库 > MySQL >

升级my.cnf时报错

最近在/etc目录下发现有一个my.cnf.rpmnew文件,应该是之前将mysql升级为mariadb时产生的。

和原来的my.cnf文件相比里面多了一些内容:

# Semisynchronous Replication
# http://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html
# uncomment next line on MASTER
;plugin-load=rpl_semi_sync_master=semisync_master.so
# uncomment next line on SLAVE
;plugin-load=rpl_semi_sync_slave=semisync_slave.so

# Others options for Semisynchronous Replication
;rpl_semi_sync_master_enabled=1
;rpl_semi_sync_master_timeout=10
;rpl_semi_sync_slave_enabled=1

# http://dev.mysql.com/doc/refman/5.5/en/performance-schema.html
;performance_schema

于是将mysql的常规配置参数复制到了该文件并改名为my.cnf。
在重启mysql时日志里发生大量错误:

140511 2:57:02 [ERROR] Missing system table mysql.roles_mapping; please run mysql_upgrade to create it
140511 2:57:02 [ERROR] Column count of mysql.events_waits_current is wrong. Expected 19, found 16. Created with MariaDB 50531, now running 100010. Please use mysql_upgrade to fix this error.
140511 2:57:02 [ERROR] Column count of mysql.events_waits_history is wrong. Expected 19, found 16. Created with MariaDB 50531, now running 100010. Please use mysql_upgrade to fix this error.
140511 2:57:02 [ERROR] Column count of mysql.events_waits_history_long is wrong. Expected 19, found 16. Created with MariaDB 50531, now running 100010. Please use mysql_upgrade to fix this error.
140511 2:57:02 [ERROR] Native table 'performance_schema'.'events_waits_summary_by_host_by_event_name' has the wrong structure
140511 2:57:02 [ERROR] Incorrect definition of table performance_schema.events_waits_summary_by_thread_by_event_name: expected column 'THREAD_ID' at position 0 to have type bigint(20), found type int(11).
140511 2:57:02 [ERROR] Native table 'performance_schema'.'events_waits_summary_by_user_by_event_name' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'events_waits_summary_by_account_by_event_name' has the wrong structure
140511 2:57:02 [ERROR] Column count of mysql.file_summary_by_event_name is wrong. Expected 23, found 5. Created with MariaDB 50531, now running 100010. Please use mysql_upgrade to fix this error.
140511 2:57:02 [ERROR] Column count of mysql.file_summary_by_instance is wrong. Expected 25, found 6. Created with MariaDB 50531, now running 100010. Please use mysql_upgrade to fix this error.
140511 2:57:02 [ERROR] Native table 'performance_schema'.'host_cache' has the wrong structure
140511 2:57:02 [ERROR] Incorrect definition of table performance_schema.mutex_instances: expected column 'LOCKED_BY_THREAD_ID' at position 2 to have type bigint(20), found type int(11).
140511 2:57:02 [ERROR] Native table 'performance_schema'.'objects_summary_global_by_type' has the wrong structure
140511 2:57:02 [ERROR] Incorrect definition of table performance_schema.rwlock_instances: expected column 'WRITE_LOCKED_BY_THREAD_ID' at position 2 to have type bigint(20), found type int(11).
140511 2:57:02 [ERROR] Native table 'performance_schema'.'setup_actors' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'setup_objects' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'table_io_waits_summary_by_index_usage' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'table_io_waits_summary_by_table' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'table_lock_waits_summary_by_table' has the wrong structure
140511 2:57:02 [ERROR] Column count of mysql.threads is wrong. Expected 14, found 3. Created with MariaDB 50531, now running 100010. Please use mysql_upgrade to fix this error.
140511 2:57:02 [ERROR] Native table 'performance_schema'.'events_stages_current' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'events_stages_history' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'events_stages_history_long' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'events_stages_summary_by_thread_by_event_name' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'events_stages_summary_by_account_by_event_name' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'events_stages_summary_by_user_by_event_name' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'events_stages_summary_by_host_by_event_name' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'events_stages_summary_global_by_event_name' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'events_statements_current' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'events_statements_history' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'events_statements_history_long' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'events_statements_summary_by_thread_by_event_name' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'events_statements_summary_by_account_by_event_name' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'events_statements_summary_by_user_by_event_name' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'events_statements_summary_by_host_by_event_name' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'events_statements_summary_global_by_event_name' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'events_statements_summary_by_digest' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'users' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'accounts' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'hosts' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'socket_instances' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'socket_summary_by_instance' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'socket_summary_by_event_name' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'session_connect_attrs' has the wrong structure
140511 2:57:02 [ERROR] Native table 'performance_schema'.'session_account_connect_attrs' has the wrong structure
140511 2:57:02 [Note] Event Scheduler: Loaded 0 events
140511 2:57:02 [Warning] Failed to load slave replication state from table mysql.gtid_slave_pos: 1146: Table 'mysql.gtid_slave_pos' doesn't exist
140511 2:57:02 [Note] /usr/libexec/mysqld: ready for connections.
Version: '10.0.10-MariaDB' socket: '/var/lib/mysql/mysql.sock' port: 0 MariaDB Server

根据提示,执行mysql_upgrade:

/usr/bin/mysql_upgrade -u root -p
service mysqld restart

网上查了下,原因是因为升级了mysql软件包后,默认数据库的表结构发生变化导致的。

(责任编辑:IT)