0
点赞
收藏
分享

微信扫一扫

MySQL问题解决集锦


文章目录

  • ​​一、mysql root权限丢失只能看到information_schema数据库​​
  • ​​二、表被锁了​​
  • ​​三、Too many connections​​
  • ​​1、临时生效​​
  • ​​2、永久生效​​
  • ​​三、Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory`​​
  • ​​`原因`​​
  • ​​`解决`​​
  • ​​四、数据库服务器I/O过高,导致不能正常访问应用​​
  • ​​`现象`​​
  • ​​`排查`​​
  • ​​`解决`​​
  • ​​增大innodb_buffer_pool_size​​

  • ​​五、mysqldump: Couldn't execute 'show fields from `表名`': Lost connection to MySQL server during query (2013)​​
  • ​​`解决`​​

一、mysql root权限丢失只能看到information_schema数据库

mysql root权限丢失只能看到information_schema数据库

二、表被锁了

MySQL表被锁了怎么办?

select * from information_schema.innodb_trx;

kill掉 trx_mysql_thead_id 下面的ID
MySQL问题解决集锦_数据库

三、Too many connections

查看当前允许的最大连接数

mysql> show global variables like '%max_connections%';

1、临时生效

set global  max_connections=3000;

2、永久生效

修改配置文件/etc/my.cnf,在[mysqld]下面添加

max_connections=3000

重启mysql

三、Authentication plugin ‘caching_sha2_password’ cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory`

​原因​

mysql8 之前的版本中加密规则是​​mysql_native_password​​​,而在mysql8之后,加密规则是​​caching_sha2_password​

​解决​

把mysql用户登录密码加密规则还原成mysql_native_password.

mysql -uroot -p密码
mysql> ALTER USER 'root'@'%' IDENTIFIED BY '密码' PASSWORD EXPIRE NEVER;
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '密码';
mysql> FLUSH PRIVILEGES;

四、数据库服务器I/O过高,导致不能正常访问应用

​现象​

ssh远程登录数据库服务器都很卡,top查看CPU和内存都正常,cpu行中的wa%却有些偏高。'状态列’有一个程序处于D状态,即不可终端的睡眠。状态D,一般是由于wait IO造成的所谓“非中断睡眠”

​排查​

iostat -x 1 10  #没有该命令需执行 yum install sysstat安装

发现IO utils%一直出于80%-97%之间,发现是系统IO达到了瓶颈。
MySQL问题解决集锦_mysql_02
用iotop查看是mysqld进程在频繁的进行IO操作
MySQL问题解决集锦_数据库服务器_03

​解决​

增大innodb_buffer_pool_size

当前是134217728字节,即128M,由于机器的内存是16G,所以把该值设置为8g
MySQL问题解决集锦_mysql_04
临时设置:

mysql> set global innodb_buffer_pool_size = 8589934592;

MySQL问题解决集锦_mysql常见问题_05
永久设置:

[mysqld]
innodb_buffer_pool_size = 8G

重启数据库

五、mysqldump: Couldn’t execute ‘show fields from ​​表名​​’: Lost connection to MySQL server during query (2013)

​解决​

加大net_read_timeout的值

mysql> show variables like '%timeout%';

MySQL问题解决集锦_数据库服务器_06
net_read_timeout默认值是30秒,我给设置为120秒

mysql> set net_read_timeout=120;

永久设置,需改/etc/my.cnf

[mysqld]
net_read_timeout=120

重启mysql


举报

相关推荐

0 条评论