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) anddatadir(data directory)1^[600-developer__database__mysql__mysql8-portable.md]. - Authentication: Defining
default_authentication_plugin=mysql_native_passwordto ensure compatibility with older clients, as MySQL 8.0 defaults tocaching_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_sizeandinnodb_log_file_sizeto 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
Post-Setup Configuration¶
After initialization, the server requires configuration to allow remote connections and set user passwords^[600-developer__database__mysql__mysql8-portable.md].
- Connect to MySQL: Use the command line client with the blank password (e.g.,
mysql -uroot -p)^[600-developer__database__mysql__mysql8-portable.md]. - Update Host: Switch to the
mysqldatabase 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'; - Flush Privileges: Apply the host changes immediately^[600-developer__database__mysql__mysql8-portable.md].
- Set Password: Alter the user to use
mysql_native_passwordand set a new password^[600-developer__database__mysql__mysql8-portable.md]:ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root'; - Restart: Stop and restart the MySQL server to apply changes^[600-developer__database__mysql__mysql8-portable.md].
Related Concepts¶
- [[MySQL]]
- [[Database initialization]]
- [[Configuration management]]
Sources¶
600-developer__database__mysql__mysql8-portable.md
-
The source example uses
D:\JavaTool\database\mysql-8.0.13-winx64for both paths. ↩