什么时候该用这个 50-mysqld_safe.cnf?
用来恢复缺失的默认文件、确认发行版本带了什么,或拿你的 MariaDB config 做 diff。
# NOTE: This file is read only by the traditional SysV init script, not systemd. # MariaDB systemd does _not_ utilize mysqld_safe nor read this file. # # For similar behaviour, systemd users should create the following file: # /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf # # To achieve the same result as the default 50-mysqld_safe.cnf, please create # /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf # with the following contents: # # [Service] # User=mysql # StandardOutput=syslog # StandardError=syslog # SyslogFacility=daemon # SyslogLevel=err # SyslogIdentifier=mysqld # # For more information, please read https://mariadb.com/kb/en/mariadb/systemd/ # [mysqld_safe] # This will be passed to all mysql clients # It has been reported that passwords should be enclosed with ticks/quotes # especially if they contain "#" chars... # Remember to edit /etc/mysql/debian.cnf when changing the socket location. socket = /var/run/mysqld/mysqld.sock nice = 0 skip_log_error syslog
curl https://exampleconfig.com/api/v1/config/original/ace3390ea785e7bb3e87bee2ef0f9da8?hint=50-mysqld_safe.cnf
wget -O 50-mysqld_safe.cnf https://exampleconfig.com/api/v1/config/original/ace3390ea785e7bb3e87bee2ef0f9da8?hint=50-mysqld_safe.cnf
<prompt><role>DevOps agent</role><source url='https://exampleconfig.com/api/v1/config/original/ace3390ea785e7bb3e87bee2ef0f9da8?hint=50-mysqld_safe.cnf' /><config><app>MariaDB</app><os>Ubuntu 20.04 LTS (Focal Fossa)</os><location>/etc/mysql/mariadb.conf.d/50-mysqld_safe.cnf</location><lines>30</lines><md5>ace3390ea785e7bb3e87bee2ef0f9da8</md5><sha256>c294caa43f63dc6328ebf7c00edc12502a5604ca3775589f631b27d7a6e4acaa</sha256></config></prompt>
粘贴到 Claude、ChatGPT 或任何 AI 助手里。
sudo apk add mariadb
sudo apt update && sudo apt install mariadb-server
sudo yum install mariadb-server
sudo apt update && sudo apt install mariadb-server
什么时候该用这个 50-mysqld_safe.cnf?
用来恢复缺失的默认文件、确认发行版本带了什么,或拿你的 MariaDB config 做 diff。
怎么恢复 MariaDB 的默认配置?
下载文件,把 /etc/mysql/mariadb.conf.d/50-mysqld_safe.cnf 里的当前配置备份好,替换掉,然后 reload 或 restart MariaDB。
50-mysqld_safe.cnf 适合直接上生产吗?
这是 Ubuntu 20.04 LTS (Focal Fossa) 的厂商默认配置,只能当基线。上生产前请检查安全和性能设置。
和其他 OS 版本有什么不同?
默认值会随发行版和版本变化,这份对应 Ubuntu 20.04 LTS (Focal Fossa)。
我可以用它来排查 MariaDB 吗?
可以。和你的配置做 diff 找出漂移,然后只恢复需要的段落。