---
title: "How to Edit the MySQL my.cnf File"
description: "In this guide, we'll show you how to make changes to your database settings in the MySQL&nbsp;my.cnf&nbsp;file. For example, you may need to increase the number of max_connections or the..."
url: https://www.inmotionhosting.com/support/server/databases/edit-mysql-my-cnf/
date: 2020-12-28
modified: 2021-08-16
author: "InMotion Hosting Contributor"
categories: ["Working with Databases"]
type: post
lang: en
---

# How to Edit the MySQL my.cnf File

![How to Edit the MySQL my.cnf File](https://www.inmotionhosting.com/support/wp-content/uploads/2020/12/Support-Center-Heros-1024x538.png)

In this guide, we’ll show you how to make changes to your database settings in the MySQL **my.cnf** file. For example, you may need to increase the number of *max_connections* or the *query_cache_size* value for your server.

To do this, you simply log in the server via SSH and edit the **my.cnf** file using an editor such as Nano. This article will explain the steps to view and edit your my.cnf file. We’ll also show you how to view your MySQL variables through SSH then how to access them in phpMyAdmin, where they can be edited.

You will need [root access](https://www.inmotionhosting.com/support/amp/obtain-root-access/) to our VPS or Dedicated server to follow this guide.

- [How to View Mysql Settings in the my.cnf File](#view-mysql-settings)
- [Editing the Mysql my.cnf File](#edit-mysql)
- [Viewing the Mysql Variables Through Shell](#view-mysql-variables-ssh)
- [Viewing MySQL Variables in phpMyAdmin](#view-mysql-variables)

**Scalable VPS Infrastructure, Fully Managed**

When shared hosting can’t handle your traffic, VPS delivers dedicated resources that scale with demand. Our team manages the technical complexity while you manage your business.

![check mark](https://design.inmotionhosting.com/assets/icons/standard/check-blue.svg)NVMe Storage    ![check mark](https://design.inmotionhosting.com/assets/icons/standard/check-blue.svg)High-Availability    ![check mark](https://design.inmotionhosting.com/assets/icons/standard/check-blue.svg)Ironclad Security    ![check mark](https://design.inmotionhosting.com/assets/icons/standard/check-blue.svg)Premium Support

[VPS Hosting](https://www.inmotionhosting.com/vps-hosting?mktgp=t&irgwc=1&affiliates=5001860&utm_campaign=Jumbotron&utm_source=supportcenter&utm_medium=cta&utm_term=vps-cta2)

![How to Edit the MySQL my.cnf File](https://i.ytimg.com/vi_webp/YHA6g3iMy_k/maxresdefault.webp)

*Don’t have time to read the article. Watch our video tutorial here.*

## How to View Mysql Settings in the my.cnf File

1. [**Login to your server via SSH**](https://www.inmotionhosting.com/support/server/ssh/how-to-login-ssh/)
2. To view the MySQL my.cnf settings **type the following**:cat /etc/my.cnf![Viewing your MySQL Settings in SSH](https://www.inmotionhosting.com/support/wp-content/uploads/2012/12/view-mysql-settings.png)The contents of the my.cnf file will display similar to the snapshot above.

## Editing the Mysql my.cnf File

1. **[Login to your server via SSH](https://www.inmotionhosting.com/support/server/ssh/how-to-login-ssh/)**.
2. To edit the MySQL settings with nano **type the following**:nano /etc/my.cnfThere are several editors you can use in shell. Nano, Vim, or Emacs. This article will focus only on Nano.![Editing your my.cnf via SSH](https://www.inmotionhosting.com/support/wp-content/uploads/2012/12/edit-mysql-file.png)
3. **Find the line to edit. **For example, if you want to edit the max_connections, find the following line.`max_connections=100`![Nano view of my.cnf max connections](https://www.inmotionhosting.com/support/wp-content/uploads/2012/12/nano-view-max-connections.png)
4. To increase the max_connections to 110 change it to the following.`max_connections=110`
5. **Enter Ctrl + O** to “*WriteOut*” or save the settings.
6. Then **Ctrl + X to exit**.
7. **Restart MySQL **by typing the following.service mysql restartNow the max_connections is increased to 110 instead of 100.

## Viewing the Mysql Variables Through Shell

![How to View MySQL Variables with SSH & phpMyAdmin](https://i.ytimg.com/vi_webp/5ti2DQHhquM/maxresdefault.webp)

1. **[Login to your server via SSH](https://www.inmotionhosting.com/support/server/ssh/how-to-login-ssh/)**.
2. Type the following command.mysqladmin variables![View of MySQL Variables](https://www.inmotionhosting.com/support/wp-content/uploads/2012/12/mysql-variables.png)The variables will display similar to the snapshot above.

## Viewing MySQL Variables in phpMyAdmin

1. **Log into your [phpMyAdmin](https://www.inmotionhosting.com/support/edu/cpanel/manage-mysql-database-in-phpmyadmin/)**.
2. Click the **Variables **tab at the top right. Then PhpMyAdmin will list all the variables and their settings on your server.![View of MySQL Variables in PhpMyAdmin](https://www.inmotionhosting.com/support/wp-content/uploads/2012/12/mysql-variables-in-phpmyadmin.png)
3. If you want to edit the values, you should edit the my.cnf file as described above.

Now you know how to edit your database settings in the MySQL my.cnf file and view database variables. For more guides check out our full section on [Working with Databases](https://www.inmotionhosting.com/support/server/databases/).
