my.cnf is a configuration file that is loaded when mysql starts, and is usually placed in the mysql installation directory, or you can load it in other directories. After installing mysql, there will be multiple my.cnf files in the system, some for testing. Use the locate my.cnf command to list all my.cnf files command locate my.cnf output
When we need to modify the configuration file, we need to find which my.cnf file was loaded when mysql started. 1. Check whether my.cnf of the specified directory is used After starting mysql, we check the mysql process to see if there is a setting to use the my.cnf file of the specified directory, if so, it means that this configuration file is loaded when mysql starts. command ps aux|grep mysql|grep 'my.cnf' output
You can see that /usr/local/Cellar/mysql/5.6.24/my.cnf is the configuration file for mysql startup loading. If the above command does not output, it means that there is no setting to use my.cnf for the specified directory. 2. Check the directory where mysql reads my.cnf by default
If you do not set my.cnf to use the specified directory, mysql will read the my.cnf file in the root directory and the default directory when mysql starts. Look at the default directory that reads the configuration file when mysql starts command mysql --help|grep 'my.cnf' output
These are:mysql searches the my.cnf directory by default, with the first priority. 3. No configuration file is used at startup If there is no setting to use the specified directory my.cnf file and the default reading directory does not have a my.cnf file, it means that the configuration file is not loaded when mysql starts, but the default configuration is used. If you need to modify the configuration, you can create a my.cnf file (for example: /etc/my.cnf) in the directory read by default in mysql, write the configuration content to be modified, and restart mysql to take effect.
|