笨猫博客

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

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

2020-03-24 6033点热度 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
取消回复

最新 热点 随机
最新 热点 随机
Afilmory - 一个现代化照片画廊网站 手把手教你用AdguradHome+SNIProxy自建DNS解锁服务器 WIN10系统彻底永久关闭自动更新 WinRAR 商业版下载安装和白嫖指南 Certbot申请谷歌免费SSL证书 宝塔面板卸载全解析:命令与脚本两种方式详解
WIN10系统彻底永久关闭自动更新WinRAR 商业版下载安装和白嫖指南Certbot申请谷歌免费SSL证书手把手教你用AdguradHome+SNIProxy自建DNS解锁服务器Afilmory - 一个现代化照片画廊网站
Gravatar头像简单介绍与使用教程 Docker 搭建音乐服务器 Navidrome 阿里云大陆免备案的两种方法实践 OneManager列表程序宝塔搭建教程 华为云新注册用户/企业实名免费6个月 我的日记记录方法
最近评论
HuangWei 发布于 3 周前(06月16日) 自己手动设置确实很烦,我之前使用过这个,感觉还不错,虽然已经不怎么维护了:https://githu...
龙笑天 发布于 1 个月前(05月25日) 一直用的萌咖的路过 :smile:
C 发布于 2 个月前(05月04日) 有个更省心的路子,上传到 catbox.moe,然后用 i0.wp.com 做加速(也支持heif格...
薯条 发布于 4 个月前(03月21日) 这个博客18年了吗,好久了哎
Q 发布于 4 个月前(03月19日) 您好: 我的一个WORDPRESS站点,安装了 wp telegram插件,我在配置了Bot ...
标签
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