I recently upgraded MySQL 5.5 to 5.6 because I needed some features but now Im not sure which my.cnf 5.6 loads...

I try editing the my.cnf in /etc with some lines such as "port=hello" but it still loads and starts correctly.

How can I see the exact route of the my.cnf it is loading? Thank you

Dani AI

Generated

— useful question. is right that the server can be told which file to use at startup; below are practical checks you can run to discover which my.cnf (if any) your running MySQL 5.6 actually read and to verify the effective values.

Run these on the server (use the same mysqld binary your service uses):

mysqld --help --verbose | sed -n '1,200p'
my_print_defaults mysqld
mysql -uroot -p -e "SHOW VARIABLES LIKE 'port';"
  • The first command prints the list of option-file locations the binary will consult (look for the "Default options are read from..." block).
  • my_print_defaults mysqld shows the options that the option files would supply to the mysqld group.
  • The SHOW VARIABLES query tells you the server’s current, in-use port value.

Check how the server was started and whether a wrapper/script set an explicit config path:

ps aux | grep -E 'mysqld|mysql'
systemctl status mysql
systemctl cat mysql   # or examine /etc/init.d/mysql

Look for any startup flag or service script that points at a specific config file, or that uses a wrapper which loads its own config.

Advanced debugging (do on a test system or during maintenance): capture open() calls at server start with strace to see which files are actually opened, and inspect the MySQL error log for warnings about option parsing. If edits to /etc/my.cnf had no effect, confirm the setting was placed under the correct group (e.g. [mysqld]) and that the server was restarted after the change.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.