The solution is as follows:
1. Check the installation location of mysql through which mysqld command
2 .View the default path of the configuration file used by mysql through the /usr/local/mysql/bin/mysqld –verbose –help |grep -A 1 ‘Default options’ command. (Note that the red mark is the command passed in step 1. Obtained mysql installation directory path)
As shown in the above figure, we can see that the order and location of mysql reading configuration file paths, first check /etc/mysql /Does the my.cnf configuration file exist below? If not, we can get a configuration file under /etc. So where does the configuration file come from?
4. Get the my.cnf configuration file
As shown in the picture above, we first switch to the support-files directory of the mysql installation directory and view the following file information through the ll command
Through cp -r /usr /local/mysql/support-files/my-default.cnf /etc/ Copy the configuration file to /etc
Switch to the /etc directory and copy the file through mv my-default.cnf my.cnf Change the name
5. Edit my.cnf, specify the mysql installation path and the mysql data file storage path. The following figure also configures bin-log. When configuring bin-log, you need to specify server_id
6. At this point, our mysql configuration file has been sorted out. You can open bin-log and restart mysql to check whether the configuration takes effect. If it takes effect, the above configuration is successful. If it cannot be started after modifying my.cnf, you can check the error message as follows
The above is the detailed content of How to install mysql default configuration file location in Linux. For more information, please follow other related articles on the PHP Chinese website!