Skip to content

MySQL portable installation

A MySQL portable installation refers to setting up the MySQL database on Windows using the ZIP Archive distribution without running a formal installer. This method relies on manual initialization and batch scripts to manage the server process^[600-developer__database__mysql__mysql8-portable.md].

Configuration

Configuration File (my.ini)

Because the server is not registered as a system service, it requires explicit configuration files and scripts to operate^[600-developer__database__mysql__mysql8-portable.md].

The portable setup uses a my.ini file to define critical paths and behaviors^[600-developer__database__mysql__mysql8-portable.md]. Key configurations include:

  • Paths: Explicitly setting the basedir (installation directory) and datadir (data directory)1^[600-developer__database__mysql__mysql8-portable.md].
  • Authentication: Defining default_authentication_plugin=mysql_native_password to ensure compatibility with older clients, as MySQL 8.0 defaults to caching_sha2_password^[600-developer__database__mysql__mysql8-portable.md].
  • Logging: Configuring paths for general logs, slow query logs, and error logs^[600-developer__database__mysql__mysql8-portable.md].
  • InnoDB Settings: Tuning parameters like innodb_buffer_pool_size and innodb_log_file_size to manage memory and disk usage for the InnoDB storage engine^[600-developer__database__mysql__mysql8-portable.md].

Initialization

To prepare the database for the first time, the mysqld executable must be run with the --initialize-insecure flag^[600-developer__database__mysql__mysql8-portable.md]. This creates the necessary data files and sets the root password to blank^[600-developer__database__mysql__mysql8-portable.md].

The initialization command typically specifies the configuration file location: mysqld --defaults-file=d:/my.ini --initialize-insecure --console^[600-developer__database__mysql__mysql8-portable.md]

Startup Script

A batch file (run.bat) is used to simplify the startup process^[600-developer__database__mysql__mysql8-portable.md]. This script navigates to the current directory and launches the daemon using the defined configuration file:

cd "%cd%"
%~dp0bin/mysqld --defaults-file=%~dp0my.ini --console
^[600-developer__database__mysql__mysql8-portable.md]

Post-Setup Configuration

After initialization, the server requires configuration to allow remote connections and set user passwords^[600-developer__database__mysql__mysql8-portable.md].

  1. Connect to MySQL: Use the command line client with the blank password (e.g., mysql -uroot -p)^[600-developer__database__mysql__mysql8-portable.md].
  2. Update Host: Switch to the mysql database and update the root user's host to % to allow connections from any host^[600-developer__database__mysql__mysql8-portable.md]: update mysql.user set host='%' where User='root' and Host='localhost';
  3. Flush Privileges: Apply the host changes immediately^[600-developer__database__mysql__mysql8-portable.md].
  4. Set Password: Alter the user to use mysql_native_password and set a new password^[600-developer__database__mysql__mysql8-portable.md]: ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
  5. Restart: Stop and restart the MySQL server to apply changes^[600-developer__database__mysql__mysql8-portable.md].
  • [[MySQL]]
  • [[Database initialization]]
  • [[Configuration management]]

Sources

  • 600-developer__database__mysql__mysql8-portable.md

  1. The source example uses D:\JavaTool\database\mysql-8.0.13-winx64 for both paths.