Enter the command: mysql --help | grep my.cnf to find the mysql configuration file path.
[root@iZ250zidl3oZ mysql]# mysql --help | grep my.cnf order of preference, my.cnf, $MYSQL_TCP_PORT, /etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf
mysql will look for the my.cnf file in the above list in turn.
If there are no configuration files in the above directories, we can copy the required configuration files in the directory (/usr/share/mysql/) to any of the above directories
[root@iZ250zidl3oZ mysql]# cp /usr/share/mysql/my-medium.cnf /etc/mysql/my.cnf
It should be noted here that excessive permissions cannot be used when assigning permissions to the my.cnf file. Otherwise mysql will ignore this configuration file.
[root@iZ250zidl3oZ mysql]# chmod 664 my.cnf
After modifying the my.cnf configuration, restart the mysql service.
[root@iZ250zidl3oZ mysql]# service mysql restart Shutting down MySQL... SUCCESS! Starting MySQL.. SUCCESS!