26
2023
04
14:32:57

解决mysql: [Warning] World-writable config file ‘/etc/mysql/mysql.conf.d/mysqld.cnf ‘ is ignored.问题

问题描述:

将/etc/mysql/mysql.conf.d/mysqld.cnf这个文件修改权限sudo chmod 777 mysqld.cnf,且重启数据库后,再次执行mysql -u root -p时,出现此警告。


#问题描述:

queena@queena-Lenovo:/etc/mysql/mysql.conf.d$ sudo chmod 777 mysqld.cnf

queena@queena-Lenovo:/etc/mysql/mysql.conf.d$ vim mysqld.cnf

queena@queena-Lenovo:/etc/mysql/mysql.conf.d$ sudo service mysql restart

queena@queena-Lenovo:/etc/mysql/mysql.conf.d$ mysql -u root -p

mysql: [Warning] World-writable config file '/etc/mysql/mysql.conf.d/mysqld.cnf' is ignored.


解决方法:

警告中World-writable 的意思就是随便哪个用户都可以修改这个配置文件,实在太不安全,所以Mysql把这个配置文件忽略了。


#将文件的权限改小即可,如下:

queena@queena-Lenovo:/etc/mysql/mysql.conf.d$ sudo chmod 644 mysqld.cnf

queena@queena-Lenovo:/etc/mysql/mysql.conf.d$ mysql -u root -p

Enter password:

......


至此问题得以解决!




故障现象:

手残把配置文件’/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

1

我想到去检查错误日志,但奇怪的是错误日志中并没有相关错误信息,还是以前的老旧信息;查看了下参数,也不是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配置文件,所以忽略掉这个配置文件。





推荐本站淘宝优惠价购买喜欢的宝贝:

image.png

本文链接:https://hqyman.cn/post/3996.html 非本站原创文章欢迎转载,原创文章需保留本站地址!

分享到:
打赏





休息一下~~


« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

请先 登录 再评论,若不是会员请先 注册

您的IP地址是: