什么时候该用这个 mysqld.cnf?
用来恢复缺失的默认文件、确认发行版本带了什么,或拿你的 MySQL config 做 diff。
# Copyright (c) 2014, 2021, Oracle and/or its affiliates. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2.0, # as published by the Free Software Foundation. # # This program is also distributed with certain software (including # but not limited to OpenSSL) that is licensed under separate terms, # as designated in a particular file or component or in included license # documentation. The authors of MySQL hereby grant you an additional # permission to link the program and your derivative works with the # separately licensed software that they have included with MySQL. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License, version 2.0, for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # The MySQL Server configuration file. # # For explanations see # http://dev.mysql.com/doc/mysql/en/server-system-variables.html [mysqld] pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock datadir = /var/lib/mysql log-error = /var/log/mysql/error.log
curl https://exampleconfig.com/api/v1/config/original/5e0569e12ba9af566f2a3db1c40d7b29?hint=mysqld.cnf
wget -O mysqld.cnf https://exampleconfig.com/api/v1/config/original/5e0569e12ba9af566f2a3db1c40d7b29?hint=mysqld.cnf
<prompt><role>DevOps agent</role><source url='https://exampleconfig.com/api/v1/config/original/5e0569e12ba9af566f2a3db1c40d7b29?hint=mysqld.cnf' /><config><app>MySQL</app><os>Debian 9 (Stretch)</os><location>/etc/mysql/mysql.conf.d/mysqld.cnf</location><lines>33</lines><md5>5e0569e12ba9af566f2a3db1c40d7b29</md5><sha256>02ad4536d09601cce66c6dda4650b5681062e72bf345ef6b13e78baa9e1994c8</sha256></config></prompt>
粘贴到 Claude、ChatGPT 或任何 AI 助手里。
sudo apt update && sudo apt install mysql-server
sudo yum install mysql-server
sudo apt update && sudo apt install mysql-server
什么时候该用这个 mysqld.cnf?
用来恢复缺失的默认文件、确认发行版本带了什么,或拿你的 MySQL config 做 diff。
怎么恢复 MySQL 的默认配置?
下载文件,把 /etc/mysql/mysql.conf.d/mysqld.cnf 里的当前配置备份好,替换掉,然后 reload 或 restart MySQL。
mysqld.cnf 适合直接上生产吗?
这是 Debian 9 (Stretch) 的厂商默认配置,只能当基线。上生产前请检查安全和性能设置。
和其他 OS 版本有什么不同?
默认值会随发行版和版本变化,这份对应 Debian 9 (Stretch)。
我可以用它来排查 MySQL 吗?
可以。和你的配置做 diff 找出漂移,然后只恢复需要的段落。