How to edit the MySQL my.cnf file in Linux VPS?

Linux VPS and Dedicated server customers can edit MySQL configuration settings by modifying my.cnf file located at /etc directory. In this article, you will learn how to view and edit my.cnf file. To do this you will have to connect to a Linux machine via SSH (with root user) and edit my.cnf file with your favorite editor.

To view the contents of the my.cnf file, run the following command.
The contents of my.cnf file will look like as shown in the following snapshot.

cat /etc/my.cnf

My Config File

Note that the content of the my.cnf file might differ depending on the operating system, control panel and several other factors. Furthermore, the lines starting with "#" are comments and they will tell you what these different settings are for.

Edit my.cnf file

To edit the MySQL settings with my.cnf file type the following command.

nano /etc/my.cnf

Find the settings you wish to edit. Say, for example, you want to increase the max_connections limit for MySQL server. Locate max_connections and set your desired value.


To increase the max_connectionsto 30 change it to the following.


Enter Ctrl + O to save the settings and Ctrl + X to exit. Restart the MySQL server by typing the following command.

service mysql restart

View MySQL variables

Type the following command to view MySQL variables. The MySQL variables will look like as shown in the following snapshot.

mysqladmin variables

Mysqladmin Variables
  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

How to Administrate MySQL Server with mysqladmin commands?

By using mysqladmin commands, you can perform basic MySQL tasks very easily, such as...

How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

Problem Statement MySQL service is stopped. Error Message 150206 4:42:12 [ERROR] Plugin...

How to fix InnoDB database corruption?

Check the log files. If you find InnoDB database corruption, follow the below mentioned steps:...

How to enable the slow query log in MySQL?

Slow MySQL queries can significantly lower down the performance of your web application and eat...

How to Fix Error Forcing close of thread 310 user: 'root' in MySQL?

Problem Statement MySQL server keeps on shutting down. Error Message C:\Program...