![更新了我的 WAMP 服务器,MySQL 占用了 580mB 的内存](https://linux22.com/image/1368903/%E6%9B%B4%E6%96%B0%E4%BA%86%E6%88%91%E7%9A%84%20WAMP%20%E6%9C%8D%E5%8A%A1%E5%99%A8%EF%BC%8CMySQL%20%E5%8D%A0%E7%94%A8%E4%BA%86%20580mB%20%E7%9A%84%E5%86%85%E5%AD%98.png)
我更新了我的 dev-box 的 WAMPSERVER,同时更新了 PHP 和 Apache,MySQL 也更新到了“5.6.12”。完成这些之后,我将数据文件夹从旧安装(5.1.36)复制到了新安装,现在 MySQL 占用了 580mB,这实在是太多了,因为我是唯一使用它的人(本地),上面只有 20 个左右的数据库,而且都没有“内存”表。
我怎样才能将其降低到一个合适的数量?
我的my.ini:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[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
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# 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
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
数据库信息:
Storage Engine Data Size Index Size Total Size
InnoDB 48.00 KB 0.00 B 48.00 KB
MEMORY 0.00 B 0.00 B 0.00 B
MyISAM 163.64 MB 122.49 MB 286.13 MB
Total 163.69 MB 122.49 MB 286.18 MB
答案1
我只会扩展“Kolerts”的答案:首先检查您正在运行的 mysql 版本,右键单击系统托盘上的 wamp 图标,将鼠标悬停在 mysql >> 上,然后在版本菜单上,您将找到它的选定版本,按照类似于 wamp/bin/mysql/mysql5.6.xx(选定版本)的路径并编辑 my.ini 文件。
找到标签 [mysqld] (通常在文件末尾)并粘贴以下内容:
table_definition_cache = 400
通常,默认包不会设置此属性。mysql 使用默认值 2000,这就是您的资源完全被它消耗的原因。如果存在此值但值较高,则只需将其降低到 400。对于单个或两个用户、轻量级用途,此值没问题,但对于大量数据等,您需要适当调整它们。
保存文件并重新启动 mysql 服务或者所有服务都遵循新的变化。
现在打开你的任务管理器并找到 mysqld 进程,你会感到笑容满面:)。
答案2
您可以在 my.ini 中设置“table_definition_cache = 400”,然后重新启动 mysqld