How to edit my.cnf

In this article we will go over how to edit the my.cnf file.  There may be times that you need to edit your mysql configuration settings, and in order to do so you will need to edit the my.cnf.  That file is found in the /etc directory.

In order to do this you will have to use the command line as the root user.  You can use the system console or you can ssh as the root user.

You can run the command cat /etc/my.cnf to view the contents of the file.  Feel free to learn more regarding the cat command.

my.cnf

The most common reason people edit their my.cnf file is to increase the max_user_connections line.  By default it is set to 50, which is quite a bit, however at times you may need to increase that.

You can do this by using vim or nano.  I prefer to use vim, but nano is an easy to use alternative.


One very important note, ALWAYS make a copy of the file you are going to edit be fore you edit it.

Use the cp command: cp /etc/my.cnf /etc/my.cnf.backup

backup my.cnf


Using vim

vim /etc/my.cnf

then press i to insert

edit the value you want to change, ie max_user_connections

press Esc

then enter :wq (the w saves and the q quits)

Now the my.cnf has been edited.

edited

Posted in Archived Posts and tagged .