这篇文章上次修改于 462 天前,可能其部分内容已经发生变化,如有疑问可询问作者。 > vps 只有1g,mysql8占用200多,原因是mysql8 默认开启了performance_schema 内存监控程序。 1.查询内存占用(前提是开启了performance_schema ) ``` sql SELECT SUBSTRING_INDEX(event_name,'/',2) AS code_area, FORMAT_BYTES(SUM(current_alloc)) AS current_alloc FROM sys.x$memory_global_by_current_bytes GROUP BY SUBSTRING_INDEX(event_name,'/',2) ORDER BY SUM(current_alloc) DESC; ``` 返回如下: ``` bash +---------------------------+---------------+ | code_area | current_alloc | +---------------------------+---------------+ | memory/performance_schema | 116.20 MiB | | memory/innodb | 72.89 MiB | | memory/mysys | 8.54 MiB | | memory/sql | 7.77 MiB | | memory/temptable | 1.00 MiB | | memory/mysqld_openssl | 134.68 KiB | | memory/mysqlx | 2.62 KiB | | memory/myisam | 696 bytes | | memory/csv | 88 bytes | | memory/blackhole | 88 bytes | | memory/vio | 16 bytes | +---------------------------+---------------+ ``` 2.宝塔---已安装软件---mysql---配置my.cnf ```bash [mysqld] performance_schema = OFF ``` 3.注意关掉这个监控程序,第1步的操作会返回空。
没有评论