Appearance
How to change a MySQL configs on DigitalOcean
Pre-requisite: You need to ssh into the server. To connect, please see here
This is the technical roadmap to change a variable:
- Freeze the platform, so no-one can do anything while you are changing the variable:
bash
php artisan down- Backup the current configuration file:
bash
sudo cp /etc/mysql/my.cnf /etc/mysql/my.cnf.backup- Open the configuration file with
vim:
bash
sudo vim /etc/mysql/my.cnfIf this file does not work, please make the changes on:
bash
sudo vim /etc/my.cnfMake the desired changes.
Restart the MySQL server:
bash
sudo service mysql restart- Unfreeze the platform:
bash
php artisan up- Remove the backup file if it’s no longer necessary:
bash
sudo rm /etc/mysql/my.cnf.backupSpecific case for putting max_connections variable
Normally, you cannot have a value of more than 214 on max_connections variable. To be able to increase that variable, you need to execute the steps below:
- Open the security file for *nix system with
vim:
bash
sudo vim /etc/security/limits.conf- Put these two lines at the bottom:
text
* hard nofile 8192
* soft nofile 4096- Open the configuration file with
vim:
bash
sudo vim /etc/mysql/my.cnf- Put these two lines below
[mysqld]:
text
open-files-limit=4096
max_connections=750- Restart the MySQL server:
bash
sudo service mysql restart- If that does not work, you might need to restart the server for security variables to take effect (and then restart the
mysqlagain):
bash
sudo reboot
sudo service mysql restart