I use ps -ef find a mysqld progress, but how can I know which conf file it using?

[root@controller data]# ps -ef | grep mysql
mysql     8901     1  0 15:15 ?        00:00:00 /usr/sbin/mysqld
root      8974   327  0 15:16 pts/0    00:00:00 grep --color=auto mysql
  • Due to cascaded loading of the configuration files, this might not be possible: stackoverflow.com/q/2482234/6216002 – Haxiel Jan 9 at 7:59
  • not only mysql, there are many progress. – 244boy Jan 9 at 8:02
  • As far as I know, a generic approach will not work here. Some applications have their configuration file specified on the command line, some don't. Some applications may not even have a configuration file. – Haxiel Jan 9 at 8:11

If you get the content of file /proc/8901/cmdline you will see what is the command line for this process and where is the config file. Here 8901 is the PID of your process. You can use also

ps -efl|grep mysql

to get long listing and in most of the case you will get entire command line

Also you can check for config file on usual places:

  • there is nothing in /proc/my PID/cmdline. – 244boy Jan 9 at 7:27
  • @244boy, please check the second idea. And also edited answer – Romeo Ninov Jan 9 at 7:30
  • Thanks, brother, I know my progress use the /etc/my.cnf, but I want to know whether there is a command for finding the using config file. – 244boy Jan 9 at 7:33
  • have you try to get the content of cmdlinewith cat /proc/my PID/cmdline? – Romeo Ninov Jan 9 at 7:35
  • there is nothing there. – 244boy Jan 9 at 7:52

Try with strace -fe trace=open mysql; that will show you all the files used for that process, including the conf file; strace is not installed by default in most of the systems but you can install it without problems from the repositories.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.