How to find MySQL default configuration file location after changing

Today, I was dealing with MySQL problems on a strange server in the company, and suddenly I found that the /etc/my.cnf file could not be found, and this server did have MySQL installed. I had no choice but to check the information. MySQL core configuration files are found on the MySQL server.

1. First look at where your mysql is, through the which command

        which mysql

        will get the following result

[zz@localhost ~]$ which mysql
/usr/bin/mysql

2. MySQL view configuration file path for this location

        /usr/bin/mysql --verbose --help | grep -A 1 'Default options' 

        The result looks like this:

[zz@localhost ~]$ /usr/bin/mysql --verbose --help | grep -A 1 'Default options'
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf

    This information means: the 
    server first reads the /etc/my.cnf file. If the previous file does not exist, it continues to read the /etc/mysql/my.cnf file. If it does not exist, it will read in order. configuration file behind.

     Finally found it under /usr/local/mysql/etc/my.cnf, the problem is solved.

        

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325885704&siteId=291194637