Mysql to view the current configuration file my. cnf (recommended), mysqlmy. cnf

Source: Internet
Author: User

Mysql to view the current configuration file my. cnf (recommended), mysqlmy. cnf

My. cnf is the configuration file loaded when mysql starts. It is usually stored in the mysql installation directory. You can also load it in other directories.

After mysql is installed, 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.

Command

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 the my. cnf file loaded at mysql startup.

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

After mysql is started, check the mysql process to see if the my. cnf file in the specified directory is configured. If yes, the configuration file is loaded when mysql is started.

Command

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

Output

Fdipzone 25174 0.0 0.0 3087244 600 ?? S pm. 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.pidfdipzone 2506 4 0.0 0.0 2452824 4 ?? S pm. 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 for mysql startup and loading.

If the preceding command has no output, it indicates that my. cnf in the specified directory is not set.

2. View mysql's default directory for reading my. cnf

If my. cnf in the specified directory is not set, mysql reads the root directory of the installation directory and the my. cnf file in the default directory at startup.

View the default directory for reading configuration files during mysql startup

Command

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 searches my. cnf by default,The priority before the sequential sorting.

3. The configuration file is not used at startup.

If the my. cnf file in the specified directory is not set and the default read directory does not contain the my. cnf file, the configuration file is not loaded when mysql is started, but the default configuration is used.

You need to modify the configuration. You can create a my. cnf file (for example:/etc/my. cnf), write the configuration content to be modified, and restart mysql to take effect.

View the current configuration file my. the cnf method (recommended) is a small part of the Content shared to everyone. I hope to give you a reference and support for the customer's house.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.