Mysql优化

死锁优化
1.执行查询命令
show processlist
2.生成杀连接命令
select concat('kill ', id, ';'),Time from information_schema.processlist where 1=1 and Time > 100 order by Time desc;

3.执行这些kill即可.

4.检查sql语句,优化那些同一语句里多个执行的语句
或者同一事务里多次更新同一表的.

5.适当扩大druid连接池
max-active: 250

6.移除超时链接,并打日志
remove-abandoned: true
remove-abandoned-timeout: 180
logAbandoned: true
检测死连接
testWhileIdle: true
配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 60000
timeBetweenEvictionRunsMillis: 60000
指明是否在从池中取出连接前进行检验,如果检验失败,则从池中去除连接并尝试取出另一个.
testOnBorrow: false
testOnReturn: false

内存占用大优化

vim /etc/my.cnf

innodb_buffer_pool_size=256M

service mysql restart 重启生效

mysql修改密码
navicat执行
UPDATE mysql.user SET Password=PASSWORD('新密码') WHERE User='root';。
刷新权限表:FLUSH PRIVILEGES;

posted @ 2023-06-01 20:51  水滴aym  阅读(11)  评论(0编辑  收藏  举报