mysql method to view the currently used configuration file my.cnf (recommended)

mysql method to view the currently used configuration file my.cnf (recommended)

my.cnf is the configuration file loaded when MySQL starts. It is usually placed in the MySQL installation directory, but users can also load it from other directories.

After installing MySQL, there will be multiple my.cnf files in the system, some of which are used for testing.

Use the locate my.cnf command to list all my.cnf files

Order

locate my.cnf

Output

/usr/local/Cellar/mysql/5.6.24/my.cnf
/usr/local/Cellar/mysql/5.6.24/mysql-test/include/default_my.cnf
/usr/local/Cellar/mysql/5.6.24/mysql-test/suite/federated/my.cnf
/usr/local/Cellar/mysql/5.6.24/mysql-test/suite/ndb/my.cnf
/usr/local/Cellar/mysql/5.6.24/mysql-test/suite/ndb_big/my.cnf
/usr/local/Cellar/mysql/5.6.24/mysql-test/suite/ndb_binlog/my.cnf
/usr/local/Cellar/mysql/5.6.24/mysql-test/suite/ndb_rpl/my.cnf
/usr/local/Cellar/mysql/5.6.24/mysql-test/suite/ndb_team/my.cnf
/usr/local/Cellar/mysql/5.6.24/mysql-test/suite/rpl/extension/bhs/my.cnf
/usr/local/Cellar/mysql/5.6.24/mysql-test/suite/rpl/my.cnf
/usr/local/Cellar/mysql/5.6.24/mysql-test/suite/rpl_ndb/my.cnf

When we need to modify the configuration file, we need to find out which my.cnf file is loaded when MySQL starts.

1. Check whether my.cnf in the specified directory is used

After starting mysql, we check the mysql process to see if there is a my.cnf file set to use the specified directory. If so, it means that this configuration file was loaded when mysql started.

Order

ps aux|grep mysql|grep 'my.cnf'

Output

fdipzone 25174 0.0 0.0 3087244 600 ?? S 4:12 PM 0:01.14 /usr/local/Cellar/mysql/5.6.24/bin/mysqld --defaults-file=/usr/local/Cellar/mysql/5.6.24/my.cnf --basedir=/usr/local/Cellar/mysql/5.6.24 --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/Cellar/mysql/5.6.24/lib/plugin --bind-address=127.0.0.1 --log-error=/usr/local/var/mysql/TerrydeMacBook-Air.local.err --pid-file=/usr/local/var/mysql/TerrydeMacBook-Air.local.pid
fdipzone 25064 0.0 0.0 2452824 4 ?? S 4:12PM 0:00.03 /bin/sh /usr/local/opt/mysql/bin/mysqld_safe --defaults-file=/usr/local/Cellar/mysql/5.6.24/my.cnf --bind-address=127.0.0.1 --datadir=/usr/local/var/mysql

You can see that /usr/local/Cellar/mysql/5.6.24/my.cnf is the configuration file loaded by mysql startup.

If the above command does not produce any output, it means that my.cnf is not set up to use the specified directory.

2. Check the directory where MySQL reads my.cnf by default

If you do not set my.cnf to use a specific directory, MySQL will read the my.cnf files in the root directory of the installation directory and the default directory when it starts.

View the default directory for reading configuration files when MySQL starts

Order

mysql --help|grep 'my.cnf'

Output

order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf
/etc/my.cnf, /etc/mysql/my.cnf, /usr/local/etc/my.cnf, ~/.my.cnf 

These are the directories where mysql will search for my.cnf by default, with the ones at the top having priority.

3. No configuration file is used at startup

If the specified directory my.cnf file is not set and there is no my.cnf file in the default reading directory, 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 in the directory that MySQL reads by default (for example: /etc/my.cnf), write the configuration content that needs to be modified, and restart MySQL to make it effective.

The above article "How to view the currently used configuration file my.cnf in MySQL" (recommended) is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed analysis of the parameter file my.cnf of MySQL in Ubuntu
  • Solution to the problem that the configuration file my.cnf in MySQL cannot be started due to permission issues
  • How to modify the default character set of MySQL to utf-8 through my.cnf and precautions
  • MySQL service performance optimization—my.cnf_my.ini configuration instructions (16G memory)
  • Introduction to /etc/my.cnf parameters in MySQL 5.7

<<:  How to configure Nginx to distinguish between PC or mobile phone access to different domain names

>>:  Detailed explanation of Docker data management (data volumes & data volume containers)

Recommend

Solution to ERROR 1054 (42S22) when changing password in MySQL 5.7

I have newly installed MySQL 5.7. When I log in, ...

28 Famous Blog Redesign Examples

1. WebDesignerWall 2. Veerle's Blog 3. Tutori...

Example code for drawing double arrows in CSS common styles

1. Multiple calls to single arrow Once a single a...

Solution to the bug that IE6 select cannot be covered by div

Use div to create a mask or simulate a pop-up wind...

Detailed explanation of using Docker to build externally accessible MySQL

Install MySQL 8.0 docker run -p 63306:3306 -e MYS...

How to smoothly go online after MySQL table partitioning

Table of contents Purpose of the table For exampl...

Detailed explanation of docker version es, milvus, minio startup commands

1. es startup command: docker run -itd -e TAKE_FI...

3 codes for automatic refresh of web pages

In fact, it is very simple to achieve this effect,...

Instructions for using the database connection pool Druid

Replace it with the optimal database connection p...

HTML table tag tutorial (23): row border color attribute BORDERCOLORDARK

In rows, dark border colors can be defined indivi...

MySQL constraint types and examples

constraint Constraints ensure data integrity and ...

How to implement email alert in zabbix

Implemented according to the online tutorial. zab...

Detailed steps to configure MySQL remote connection under Alibaba Cloud

Preface As we all know, by default, the MySQL ins...