MySQL Installation Guide
Installing on Windows
Using MySQL Installer
MySQL Installer is the easiest way to install MySQL on Windows, providing a wizard-based installation experience.
Download MySQL Installer Visit https://dev.mysql.com/downloads/installer/ to download the installer.
Run the Installer Double-click the downloaded MSI file to start the installation wizard.
Choose Installation Type
- Full: Install all MySQL products and features
- Developer Default: Suitable for development environment
- Server Only: Install MySQL Server only
- Custom: Choose specific components to install
Configure MySQL Server
- Select MySQL Server version
- Set port number (default 3306)
- Choose startup type
Set Root Password Set a strong password for the MySQL administrator account.
Complete Installation Follow the wizard to finish the installation process.
Manual Installation Using ZIP Archive
Download MySQL ZIP Package Visit https://dev.mysql.com/downloads/mysql/ to download the ZIP archive.
Extract Files Extract the ZIP archive to your desired directory, such as C:\mysql.
Initialize Data Directory
mysqld --initialize-insecureStart MySQL Service
mysqld --install MySQL net start MySQLLogin and Change Password
mysql -u root -p ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
Installing on Linux
Ubuntu/Debian Systems
Update Package Index
sudo apt updateInstall MySQL Server
sudo apt install mysql-serverStart MySQL Service
sudo systemctl start mysql sudo systemctl enable mysqlSecure Installation
sudo mysql_secure_installation
CentOS/RHEL Systems
Add MySQL Yum Repository
sudo yum install https://dev.mysql.com/get/mysql80-community-release-el8-4.noarch.rpmInstall MySQL Server
sudo yum install mysql-community-serverStart Service
sudo systemctl start mysqld sudo systemctl enable mysqldGet Temporary Password
sudo grep 'temporary password' /var/log/mysqld.log
Installing on macOS
Using Homebrew
Install Homebrew (if not installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Install MySQL
brew install mysqlStart MySQL Service
brew services start mysqlSecure Installation
mysql_secure_installation
Using DMG Package
Download DMG Package Visit https://dev.mysql.com/downloads/mysql/ to download the macOS DMG package.
Run Installer Double-click the PKG file and follow the wizard to complete installation.
Start MySQL Start MySQL service through System Preferences.
Installing MySQL with Docker
Pull MySQL Image
docker pull mysql:latest
Run MySQL Container
docker run -d \
--name mysql-container \
-e MYSQL_ROOT_PASSWORD=your_password \
-e MYSQL_DATABASE=testdb \
-p 3306:3306 \
mysql:latest
Common Docker Parameters
-e MYSQL_ROOT_PASSWORD: Set root password-e MYSQL_DATABASE: Create initial database-p 3306:3306: Port mapping-v /data/mysql:/var/lib/mysql: Volume for data persistence
Verifying Installation
Check MySQL Version
mysql --version
Check Service Status
systemctl status mysql # Linux
brew services list # macOS
Login to MySQL
mysql -u root -p
Common Installation Issues
Port Conflicts
If port 3306 is in use, either modify the port in the configuration file or stop the service using that port.
Permission Issues
On Linux, use sudo to elevate permissions and ensure the data directory has correct read/write permissions.
Firewall Settings
Ensure the firewall allows access to port 3306.
