my.cnf
for Linux and Mac systemsmy.ini
for Windows systems
- They can be compiled into the executable server program when built from source code.
- They can be specified as command-line options when the server starts.
- They can be set in the MySQL configuration file.
Most MySQL server installations use a combination of compiling some basic settings into the executable server program and creating a basic configuration file for the rest. The setting values set in the configuration file override anything compiled into the executable server program or set on the command line.
As with the Apache web server, the MySQL database server has lots of options you can change in the configuration file to fine-tune how things work. That said, there are only a few items that you’d ever really need to tweak in a normal setup.
The core server settings
The core server settings define the basics of how the MySQL server operates. These settings in the XAMPP for Windows setup look like this:[mysqld]Theport = 3306
socket = "C:/xampp/mysql/mysql.sock"
basedir = "C:/xampp/mysql"
tmpdir = "C:/xampp/mysql/tmp"
datadir = "C:/xampp/mysql/data"
log_error = "mysql_error.log"
port
setting defines the TCP port the MySQL server listens for incoming requests on. The socket
setting defines the location of a socket file that local clients can use to communicate with the MySQL server without using the network.The basedir
, tmpdir
, and datadir
settings define the locations on the server that MySQL will use for storing its working files. The datadir
setting defines where MySQL stores the actual database files.
Working with the InnoDB storage engine
The InnoDB storage engine provides advanced database features for the MySQL server. It has its own set of configuration settings that control exactly how it operates and how it handles the data contained in tables that use that storage engine.There are two main configuration settings that you may need to tweak for your specific MySQL server installation:
innodb_data_home_dir = "C:/xampp/mysql/data"Theinnodb_data_file_path = ibdata1:10M:autoextend
innodb_data_home_dir
setting defines the location where MySQL places files required to support the InnoDB storage engine. This allows you to separate those files from the normal MySQL database files if needed.The innodb_data_file_path
setting defines three pieces of information for the storage engine:
- The filename MySQL uses for the main InnoDB storage file
- The initial size of the storage file
- What happens when the storage file fills up
The third parameter is where things get interesting. It defines what the InnoDB storage engine does when the space allocated for the storage file becomes full. By default, the InnoDB storage engine will block new data inserts to the tables when it runs out of allocated storage space. You would have to manually extend the storage file size.
When you specify the autoextend
setting, that allows the InnoDB storage engine to automatically allocate more space for the file. That’s convenient, but it can also be dangerous in some environments. The InnoDB storage engine will keep allocating more storage space as needed until the server runs out of disk space!
When you use the InnoDB storage engine for your MySQL applications, it’s always a good idea to keep an eye on the storage space folder to make sure it’s not taking up all the server disk space.