代码连MySQL从库报“Table ‘performance_schema.session_var”

问题背景:

有两台mysql,一主一从,开发在代码里面连MySQL集群,发现有报错。连主库单点OK,连从库单点报错:

Table ‘performance_schema.session_variables‘ doesn‘t exist
Could not create connection to database server. Attempted reconnect 3 times. Giving up.

在数据库从库执行mysql> show global status like "%abort%";,报如下错误:

mysql> show global status like "%abort%";
ERROR 1146 (42S02): Table ‘performance_schema.global_status‘ doesn‘t exist

解决方法:

参考网上的解决文档,在mysql从库命令行执行命令:

sudo mysql_upgrade -u root -p –force

执行结果如下:

[[email protected] mysql]# mysql_upgrade -u root -p –force
Enter password:       #这里输入数据库root用户的密码
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Checking system database.
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.engine_cost                                  OK
mysql.event                                        OK
mysql.func                                         OK
mysql.general_log                                  OK
mysql.gtid_executed                                OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.innodb_index_stats                           OK
mysql.innodb_table_stats                           OK
mysql.ndb_binlog_index                             OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.server_cost                                  OK
mysql.servers                                      OK
mysql.slave_master_info                            OK
mysql.slave_relay_log_info                         OK
mysql.slave_worker_info                            OK
mysql.slow_log                                     OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
Upgrading the sys schema.
Checking databases.
ApolloConfigDB.App                                 OK
ApolloConfigDB.AppNamespace                        OK
ApolloConfigDB.Audit                               OK

#中间省略若干业务库和表

locman.process_node_person                         OK
locman.process_type_base                           OK
monitor.dubbo_invoke                               OK
operations.app_install                             OK
operations.app_install_status                      OK
operations.auth_group                              OK
operations.auth_group_permissions                  OK
operations.auth_permission                         OK
operations.auth_user                               OK
operations.auth_user_groups                        OK
operations.auth_user_user_permissions              OK
operations.business_admin                          OK
operations.celery_taskmeta                         OK
operations.celery_tasksetmeta                      OK
operations.cluster                                 OK
operations.django_admin_log                        OK
operations.django_content_type                     OK
operations.django_migrations                       OK
operations.django_session                          OK
operations.djcelery_crontabschedule                OK
operations.djcelery_intervalschedule               OK
operations.djcelery_periodictask                   OK
operations.djcelery_periodictasks                  OK
operations.djcelery_taskstate                      OK
operations.djcelery_workerstate                    OK
operations.host_ps                                 OK
operations.jenkins_jobs                            OK
operations.module                                  OK
operations.operation_log                           OK
operations.project_center                          OK
operations.project_center_deploy_salt_minion       OK
operations.project_deploy_info                     OK
operations.project_docker_info                     OK
operations.project_image_save                      OK
operations.receiver_hooks                          OK
operations.salt_master                             OK
operations.salt_minion                             OK
operations.salt_minion_module                      OK
sys.sys_config                                     OK
Upgrade process completed successfully.
Checking if update is needed.

然后再重启数据库从库:

[[email protected] ~]# systemctl restart mysqld

然后开发再用代码重新连MySQL,就可以正常连了。从库执行show global status like "%abort%";也没有报错了

mysql> show global status like "%abort%";
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| Aborted_clients  | 1     |
| Aborted_connects | 0     |
+------------------+-------+
2 rows in set (0.00 sec)

mysql> 

然后从库检查主从复制情况,一切正常

参考文档:
https://stackoverflow.com/questions/31967527/table-performance-schema-session-variables-doesnt-exist

原文地址:http://blog.51cto.com/10950710/2122017

时间: 2024-12-19 00:57:40

代码连MySQL从库报“Table ‘performance_schema.session_var”的相关文章

修复mysql:[ERROR] Native table ‘performance_schema’

转: http://www.amznz.com/error-native-table-performance_schema/ mysql数据库出现如下错误,主要是因为升级了mysql软件包,而一些数据库的表结构发生变化而无法正常运行. 140213 16:55:47 [ERROR] Native table 'performance_schema'.'events_waits_current' has the wrong structure140213 16:55:47 [ERROR] Nati

运行mysql时,提示Table ‘performance_schema.session_variables’ doesn’t exist

解决的方法是: 第一步:在管理员命令中输入: mysql_upgrade -u root -p --force 第二步:重新启动mysql的服务: net stop mysql net start mysql 再次运行MySQL,就解决了. 注意,两步缺一不可.

Table ‘performance_schema.session_variables’ doesn’t exist

运行mysql时,提示Table ‘performance_schema.session_variables’ doesn’t exist 解决的方法是: 第一步:在管理员命令中输入: mysql_upgrade -u root -p --force 第二步:重新启动mysql的服务: net stop mysql net start mysql 再次运行mysql,就解决了. 注意,两步缺一不可.

MySql重装以后,修改数据库路径,打开以前的数据库报Table 'XX库.XX表' doesn't exist错误的解决办法

因为mysql主流的数据库引擎有MyISAM和InnoDB两种, 如果是MyISAM,直接把以前数据库拷贝到修改后的路径是可以的 但是InnoDB因为存储结构不同,必须还得把备份的innodb数据库表“*.frm”文件和innodb数据“ibdata1”文件拷到修改后的合适路径 参考资料:http://www.bcty365.com/content-35-2928-1.html https://blog.csdn.net/dihuangtian01/article/details/5177353

Linux环境下MySQL报Table 'xxx' doesn't exist错误解决方法

修改了lower_case_table_names=1 后,业务发有个库的表打不开了,看了表名以前是大写,查了一下如果设置不区分大小写, 以前的大小表名要改成小写.重启服务后可用! MYSQL在LINUX下数据库名.表名.列名.别名大小写规则如下: 1.数据库名与表名是严格区分大小写的 2.表的别名是严格区分大小写的 3.列名与列的别名在所有的情况下均是忽略大小写的 4.变量名也是严格区分大小写的 Linux环境下MySQL报Table 'xxx' doesn't exist错误解决方法

linux上的mysql报Table 'xxx' doesn't exist的错误解决方法

linux上的mysql报Table 'xxx' doesn't exist的错误解决方法 问题:程序报Table 'xxx' doesn't exist 的错误,但是查看数据库发现该表已经存在且字母也没有拼错. 原因:linux 上的mysql 默认是区分大小写导致的. 解决:改动mysql的配置文件,在my.cnf中的[mysqld]下面(位置不能错)加上lower_case_table_name=1这句(1表示不区分大小写,0区分大小写),保存重新启动mysql. 没有my.cnf文件,如

mysql从库Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'报错处理

年后回来查看mysql运行状况与备份情况,登录mysql从库查看主从同步状态 1 mysql> show slave status\G; 2 *************************** 1. row *************************** 3 Slave_IO_State: 4 Master_Host: 101.200.*.* 5 Master_User: backup 6 Master_Port: 3306 7 Connect_Retry: 60 8 Master_

mysql 更新sql报错:You can't specify target table 'wms_cabinet_form' for update in FROM clause

数据库里面有两个字段的位置不对,要把他们对调换下.因为没有数据库写的权限,需要用sql语句来实现.原来以为简单的 update table a set a.字段a=(select b字段 from table  where id=?) ,set a.字段b=(select a字段 from table where id=?) where id=? ,结果报了 这个问题 You can't specify target table 'wms_cabinet_form' for update in

mysql Table 'performance_schema.session_variables' doesn't exist

CMD  进入MYSQL的安装目录..Bin 下 执行 mysql_upgrade -u root -p --force 输入密码..然后等待一会儿..会跑一些东西..然后重启服务 mysql Table 'performance_schema.session_variables' doesn't exist