笨猫博客

  • 🍟首页
  • 🍘目录
    • 🥝VPS教程
    • 🍾猫玩技术
    • 🍹干货分享
    • 🍏软件分享
    • 🍩一只猫
  • 🍋工具
    • 🌽IP路由追踪
    • 🍐域名Whois查询
    • 🥘域名被墙查询
    • 🍧IP正常检测
    • 🔥IP端口检测
    • 🍆短网址
    • 🐟VIP音乐播放
    • 🍯KMS激活
  • 🍓链接
  • 🍪联系
  • 🍱登录
    • 🥦登录
    • 🍒注册
关注互联网,生活,音乐,乐此不疲的一只笨猫
  1. 首页
  2. VPS教程
  3. 正文

mysql 5.6与5.7内存参数优化内存占用为30MB左右

2020-03-24 6280点热度 2人点赞 0条评论

说明:mysql 5.6、5.7默认启动占用内存400多M,如果是vps等小内存应用,mysql内存占用率明显偏高,将会导致崩溃,mysql会自动停止。
编辑/etc/my.cnf文件在[mysqld]下增加或修改如下参数

performance_schema_max_table_instances = 200

table_definition_cache = 100

table_open_cache = 100。

这个三个参数,调低值后内存能明显减小,现在mysql使用内存约60MB左右,就大大降低默认使用的内存。

进一步调整参数

innodb_buffer_pool_size=2M

这个三个参数可以调小。 再进一步调整: mysql 5.6默认启用performance_schema,占用很多内存,可以禁用。

完整配置文件如下,内存占用到22M

我的mysql配置如下,如果你使用的centos6 64位,并且是yum安装的(一键脚本)可以自己按照如下照抄,我的是centos6 64位系统

先ssh登录服务器或VPS,在vi /etc/my.cnf

# For advice on how to change settings please see

# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html

[mysqld]

#

# Remove leading # and set to the amount of RAM for the most important data

# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

# innodb_buffer_pool_size = 128M

#

# Remove leading # to turn on a very important data integrity option: logging

# changes to the binary log between backups.

# log_bin

#

# Remove leading # to set options mainly useful for reporting servers.

# The server defaults are faster for transactions and fast SELECTs.

# Adjust sizes as needed, experiment to find the optimal values.

# join_buffer_size = 128M

# sort_buffer_size = 2M

# read_rnd_buffer_size = 2M

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

#symbolic-links=0

skip-external-locking

key_buffer_size = 8M

max_allowed_packet = 1M

table_open_cache = 4

sort_buffer_size = 64K

read_buffer_size = 256K

read_rnd_buffer_size = 256K

net_buffer_length = 2K

thread_stack = 240K

#innodb_use_native_aio = 0

innodb_buffer_pool_size=2M

performance_schema_max_table_instances=50

table_definition_cache=50

table_open_cache=32

max_connections=50

max_user_connections=35

wait_timeout=10

interactive_timeout=15

long_query_time=5

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

# Recommended in standard MySQL setup

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

默认值如下:

performance_schema_max_table_instances 12500

table_definition_cache 1400

table_open_cache 2000
标签: MYSQL 优化内存 内存参数
最后更新:2020-03-12

笨猫

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

最新 热点 随机
最新 热点 随机
Aeroshell 智能终端-你的运维好帮手 过滤iOS烦人的开屏广告18Bit DNS 忘掉“学”英语,开始“接触”英语!一键给你的浏览器装一个“英语环境”生成器 软软一键开关 --提供多个 Windows 系统开关,例如保持常亮、隐藏桌面图标 2025年Shadowrocket(小火箭)最新苹果ios配置使用图文教程 MoonTV 客户端 v1.0.0 发布!
忘掉“学”英语,开始“接触”英语!一键给你的浏览器装一个“英语环境”生成器软软一键开关 --提供多个 Windows 系统开关,例如保持常亮、隐藏桌面图标过滤iOS烦人的开屏广告18Bit DNSAeroshell 智能终端-你的运维好帮手
精子,养肾学 在线密码管理专家豌豆网(Onedoor)推出个性化主页服务 QQ屏蔽大部分CN域名 阿里云大陆免备案的两种方法实践 用 Service Workers 为网站加速 Win11 v22H2(22621.2070)_不忘初心游戏版
最近评论
dk 发布于 1 个月前(09月22日) 哈哈哈哈
天天下载Ttzip 发布于 2 个月前(09月15日) 很棒的网站!感谢分享,谢谢站长!!@天天下载Ttzip
诗音 发布于 2 个月前(08月29日) 时间改到2099年在暂停更新也可以
vip券网 发布于 3 个月前(08月01日) 写的很详细,赞 :razz: :evil:
萧瑟 发布于 4 个月前(07月14日) 这个我也用了好久,不知道啥时候能上IP证书
标签
elliptictrue100.10.02
BLOG ChatGPT Chrome CloudFlare DirectAdmin github Godaddy google kloxo Linux OneDrive OneIndex PHP QQ shadowsocks SNS ssh Typecho VPS web2.0 whmcs Windows wordpress 一键脚本 下载 免费 博客 图文教程 图标 图片 域名 头像 奥运 宝塔面板 插件 教程 日记 有趣 浏览器 游戏 猫 生活 电影 百度 网站 视频 设计 软件 阿里云盘 音乐
好友
  • glzjin's blog glzjin's blog
  • ZAERA博客
  • 冰沫记
  • 奇它博客
  • 猫腻‘s Blog
  • 猫饭
  • 肥宅之家
  • 萌博
  • 野路子程序员

COPYRIGHT © 2022 笨猫博客. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang