MySQL Configuration File - Updating and changing the default location of my.cnf
MySQL Option file or Configuration file
Most MySQL programs can read startup options from option files (also called as configuration files).
Option files provide a convenient way to specify commonly used options so that they need not be entered on the command line each time you run a program.
File path: /etc/my.cnf
The mysqld --verbose --help is used to display detailed information about the mysql server's configurations, options, and supported features.
To check the contents of the my.cnf file :
sudo nano /etc/my.cnf
Let's update our configuration file now.
We will remove all the comments and one option of 'server-id', for which we will assign the value as 1.
To check for the serer-id in MySQL you execute this command:
show variables like '%server_id%';
As you can see the server_id is 1. Now let's update this in our option file.
In our configuration file we will add the following line:
server-id=1
Notice, that our system variable uses underscores, but in configuration file we use '-' instead of '_'.
Your configuration should look something like this.
Now let's change the default file location of our configuration file (Optional)
Great! You have successfully changed the default location of the configuration file
Now let's say instead of /etc/mysql/my.cnf, I want my configuration file to be in the /etc/percona directory. How can i achieve this ?
We can do this with the help of !include or !includedir



Comments
Post a Comment