VPS Hosting and Dedicated server customers can edit MySQL configuration settings by modifying my.cnf file located in the /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
Note that the content of my.cnf file might differ depending on the operating system, control panel, and several other factors. Furthermore, the lines starting with "#" are comments that 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 the MySQL server. Locate max_connections and set your desired value.
max_connections=20
To increase the max_connections to 30, change it to the following.
max_connections=30
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