Using parameters with MySQL startup script


MySQL, an open-source relational database management system, is a popular choice among developers for managing and organizing data. A startup script is crucial in controlling the server’s behavior during startup. In this article, we’ll explore various parameters that can be used with MySQL startup scripts and provide examples to better understand their usage.

Table of Contents

  1. Basics of MySQL Startup Script
  2. Commonly Used Parameters
  3. Customizing the MySQL Configuration File
  4. Starting MySQL with Multiple Instances
  5. Security Considerations
  6. Troubleshooting MySQL Startup Issues
  7. Basics of MySQL Startup Script

Basics of MySQL Startup Script

MySQL server is typically started using the ‘mysqld’ command, followed by several optional parameters that control the server’s behavior. These parameters can be passed to the startup script directly or added to the MySQL configuration file (my.cnf or my.ini).


mysqld --port=3306 --datadir=/var/lib/mysql --socket=/var/run/mysqld/mysqld.sock

Commonly Used Parameters

  • –port: Defines the port number on which the MySQL server will listen for connections.
  • –datadir: Specifies the location of the data directory containing the databases.
  • –socket: Indicates the path of the UNIX socket file used for local connections.
  • –user: Sets the operating system user under which the MySQL server will run.
  • –bind-address: Configures the server’s IP address to listen for incoming connections.
  • –skip-networking: Disables networking support, allowing only local connections.


mysqld --port=3307 --datadir=/var/lib/mysql2 --user=mysql --bind-address=

Customizing the MySQL Configuration File

Instead of providing parameters directly in the command line, you can add them to the MySQL configuration file (my.cnf on Unix-based systems or my.ini on Windows).

Example of my.cnf:


Starting MySQL with Multiple Instances

To run multiple MySQL instances, create separate configuration files and data directories for each instance. Specify the respective configuration file when starting each instance using the –defaults-file parameter.


mysqld --defaults-file=/etc/mysql/my1.cnf
mysqld --defaults-file=/etc/mysql/my2.cnf

Security Considerations

  • –skip-grant-tables: Starts the server without loading the grant tables, enabling unrestricted access to all databases. Use this parameter with caution and only for troubleshooting purposes.
  • –require_secure_transport: Forces connections to the server to use secure transports like SSL or TLS.
  • –secure-file-priv: Restricts the server’s file I/O to a specific directory for security purposes.


mysqld --require_secure_transport=ON --secure-file-priv=/var/lib/mysql-files

Troubleshooting MySQL Startup Issues

  • –log-error: Specifies the location of the error log file, which records any issues encountered during the server startup.
  • –general-log: Enables the general query log, which records client connections and statements received from clients.


mysqld --log-error=/var/log/mysql/error.log --general-log=1 --general-log-file=/var/log/mysql/general.log


Understanding how to use parameters with MySQL startup scripts is essential for managing and customizing your MySQL server. These parameters allow you to control various aspects of the server, such as connection settings, security, and logging. By combining the right set of parameters, you can configure your MySQL server to meet your specific needs, optimize its performance, and troubleshoot any issues that may arise during its operation. Make sure to refer to the MySQL documentation for a comprehensive list of parameters and their detailed explanations.

Related Articles