MySQL重启也无法解决的Warning: World-writable config file '/etc/mysql/my.cnf' is ignored

故障现象:
手残把配置文件’/etc/mysql/my.cnf’ 的权限设置成 “777” 了,在centos7.6环境下,使用rpm包方式安装的mysql5.7.29,在使用命令systemctl stop mysqld;systemctl start mysqld命令重启后,无任何报错反馈。也可以连接到mysql实例,但是紧接着一行warning出现,如下:

Warning: World-writable config file '/etc/mysql/my.cnf' is ignored

我想到去检查错误日志,但奇怪的是错误日志中并没有相关错误信息,还是以前的老旧信息;查看了下参数,也不是my.cnf中预设的参数,全部是默认的参数。数据库实例重启多次,同样的现象发生,哪怕给我报个错也好啊。
问题分析:
首先想到的是手工起来下,注意不要加入后台,否则看不到日志:
/usr/sbin/mysqld --defaults-file=/etc/my.cnf --user=root

mysqld: [Warning] World-writable config file '/etc/my.cnf' is ignored.
2020-02-22T12:54:57.183666Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-02-22T12:54:57.185141Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.29) starting as process 4328 ...
2020-02-22T12:54:57.189939Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-02-22T12:54:57.189977Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-02-22T12:54:57.189984Z 0 [Note] InnoDB: Uses event mutexes
2020-02-22T12:54:57.189989Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-02-22T12:54:57.189994Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-02-22T12:54:57.189999Z 0 [Note] InnoDB: Using Linux native AIO
2020-02-22T12:54:57.190374Z 0 [Note] InnoDB: Number of pools: 1
2020-02-22T12:54:57.190515Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-02-22T12:54:57.192619Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-02-22T12:54:57.203455Z 0 [Note] InnoDB: Completed initialization of buffer pool
2020-02-22T12:54:57.205683Z 0 [Note] InnoDB: page_cleaner coordinator priority: -20
2020-02-22T12:54:57.217941Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2020-02-22T12:54:57.231390Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-02-22T12:54:57.231490Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-02-22T12:54:57.258809Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-02-22T12:54:57.259595Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2020-02-22T12:54:57.259611Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2020-02-22T12:54:57.260482Z 0 [Note] InnoDB: Waiting for purge to start
2020-02-22T12:54:57.310865Z 0 [Note] InnoDB: 5.7.29 started; log sequence number 229348461
2020-02-22T12:54:57.311288Z 0 [Note] Plugin 'FEDERATED' is disabled.
2020-02-22T12:54:57.317418Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2020-02-22T12:54:57.317443Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2020-02-22T12:54:57.318170Z 0 [Warning] CA certificate ca.pem is self signed.
2020-02-22T12:54:57.318216Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2020-02-22T12:54:57.318588Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2020-02-22T12:54:57.318623Z 0 [Note] IPv6 is available.
2020-02-22T12:54:57.318631Z 0 [Note]   - '::' resolves to '::';
2020-02-22T12:54:57.318646Z 0 [Note] Server socket created on IP: '::'.
2020-02-22T12:54:57.319403Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2020-02-22T12:54:57.321470Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200222 20:54:57
2020-02-22T12:54:57.329784Z 0 [Note] Event Scheduler: Loaded 0 events
2020-02-22T12:54:57.330489Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.7.29'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)

这下终于看到日志了,虽然最后mysql实例起来了,但是有熟悉的告警信息mysqld: [Warning] World-writable config file ‘/etc/my.cnf’ is ignored. ,日志中也看到加载了很少的选项,也没有把错误日志输出到文件中,这也就是systemctl start mysqld之后看不到错误日志的原因。
看来问题的关键就在于那个错误提示了,改回去吧。

[root@rpmtest ~]# chmod 644 /etc/my.cnf
[root@rpmtest ~]# ls -l /etc/my.cnf
-rw-r--r-- 1 root root 2016 Feb 22 19:59 /etc/my.cnf

重启后mysql实例恢复正常,也可以看到有正常的错误日志,参数也应用了/etc/my.cnf里面配置的。

总结:
1、看似mysql实例起来了,其实没有加载/etc/my.cnf配置文件,如果不注意Warning信息,很容易留坑。
2、mysql出于安全的考虑,担心其他用户可以恶意修改my.cnf配置文件,所以忽略掉这个配置文件。

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值