Modify MySQL Settings
ServBay comes with a MySQL database and offers flexible configuration options. This document will detail how to modify MySQL settings in ServBay, including the location of configuration files and common configuration items. Depending on the MySQL version, these files are located in the /Applications/ServBay/etc/mysql/<version>
directory.
Important Note
Please do not manually modify configuration files. All configuration files are automatically generated by ServBay, and manual modifications could be overwritten. Use the UI interface for any changes.
Modifying via the ServBay UI
ServBay includes a powerful graphical management interface that allows users to directly modify different configuration parameters. Once you click save, changes are automatically applied and take effect in real time, eliminating the hassle of manually editing parameters.
Users can navigate through ServBay's left sidebar, select Database
- MySQL
, and then choose the corresponding version to edit and modify the MySQL configuration.
In the graphical editing interface, in addition to obtaining the default MySQL username and root password, users can modify MySQL's listening address bind-address
and port port
(default is 0.0.0.0:3306
). Users can also enable the recording of slow query log
and configure MySQL's max_connections
, max_allowed_packet
, and other settings.
Once users have completed modifications, clicking the Save
button will apply the changes and take effect immediately.
Modifying by Manually Editing Configuration Files
WARNING
Editing configuration files manually is only suitable for temporary changes to some configuration items.
We do not recommend modifying MySQL configuration files manually. Since all changes will be overwritten by ServBay.
Overview
In ServBay, MySQL configuration files are stored in different directories depending on the version. For example, the configuration file for MySQL 9.0 is located in the /Applications/ServBay/etc/mysql/9.0
directory. The main configuration file is my.cnf
.
Configuration File Location
my.cnf
:/Applications/ServBay/etc/mysql/<version>/my.cnf
my.cnf
my.cnf
is the main configuration file for MySQL, used to set runtime options for the database server.
Common Configuration Items
Modify the Listening Address:
[mysqld] bind-address = 0.0.0.0
1
2Modify Port Number:
[mysqld] port = 3306
1
2Modify Max Connections:
[mysqld] max_connections = 200
1
2Modify Buffer Pool Size:
[mysqld] innodb_buffer_pool_size = 256M
1
2Modify Log File Path:
[mysqld] log_error = /Applications/ServBay/logs/mysql/error.log
1
2Enable Slow Query Log:
[mysqld] slow_query_log = 1 slow_query_log_file = /Applications/ServBay/logs/mysql/slow.log long_query_time = 2 # Records queries taking longer than 2 seconds
1
2
3
4Modify Character Set and Collation:
[mysqld] character-set-server = utf8mb4 collation-server = utf8mb4_unicode_ci
1
2
3
Restarting MySQL
After modifying the MySQL configuration file, you need to restart the MySQL service for the changes to take effect. You can restart it using ServBay's management interface or the servbayctl
command-line tool.
Restart via ServBay Management Interface
- Open the ServBay management interface.
- Navigate to
Services
. - Find the corresponding version of the MySQL service and click the
Restart
button.
Restart via servbayctl
You can conveniently restart the MySQL service using the servbayctl
command-line tool:
servbayctl restart mysql 9.0
Summary
In ServBay, MySQL configuration files are located in the /Applications/ServBay/etc/mysql/<version>
directory, including my.cnf
. After modifying these configuration files, you can restart the MySQL service via ServBay's management interface or using the servbayctl
command-line tool to apply the changes.