在CentOS下,MySQL的配置文件通常位于/etc/my.cnf。
以下是一個(gè)基本的MySQL配置文件的示例:
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Settings to enhance security bind-address=127.0.0.1 skip-networking pid-file=/var/run/mysqld/mysqld.pid # Character set configuration character-set-server=utf8mb4 collation-server=utf8mb4_unicode_ci # InnoDB configuration default-storage-engine=InnoDB innodb_file_per_table=1 innodb_buffer_pool_size=256M innodb_flush_log_at_trx_commit=2 innodb_log_buffer_size=8M innodb_max_dirty_pages_pct=75 innodb_lock_wait_timeout=50 [mysql] default-character-set=utf8mb4 [mysqldump] default-character-set=utf8mb4
以上配置文件包含了一些關(guān)鍵的 MySQL 服務(wù)器設(shè)置,如 InnoDB 表引擎和字符集設(shè)置等。這些設(shè)置基本上會(huì)覆蓋默認(rèn)值,并使服務(wù)器更加穩(wěn)定和安全。
建議根據(jù)實(shí)際情況對(duì)配置文件進(jìn)行適當(dāng)?shù)男薷摹?/p>