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.

  1. Download MySQL Installer Visit https://dev.mysql.com/downloads/installer/ to download the installer.

  2. Run the Installer Double-click the downloaded MSI file to start the installation wizard.

  3. 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
  4. Configure MySQL Server

    • Select MySQL Server version
    • Set port number (default 3306)
    • Choose startup type
  5. Set Root Password Set a strong password for the MySQL administrator account.

  6. Complete Installation Follow the wizard to finish the installation process.

Manual Installation Using ZIP Archive

  1. Download MySQL ZIP Package Visit https://dev.mysql.com/downloads/mysql/ to download the ZIP archive.

  2. Extract Files Extract the ZIP archive to your desired directory, such as C:\mysql.

  3. Initialize Data Directory

    mysqld --initialize-insecure
    
  4. Start MySQL Service

    mysqld --install MySQL
    net start MySQL
    
  5. Login and Change Password

    mysql -u root -p
    ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
    

Installing on Linux

Ubuntu/Debian Systems

  1. Update Package Index

    sudo apt update
    
  2. Install MySQL Server

    sudo apt install mysql-server
    
  3. Start MySQL Service

    sudo systemctl start mysql
    sudo systemctl enable mysql
    
  4. Secure Installation

    sudo mysql_secure_installation
    

CentOS/RHEL Systems

  1. Add MySQL Yum Repository

    sudo yum install https://dev.mysql.com/get/mysql80-community-release-el8-4.noarch.rpm
    
  2. Install MySQL Server

    sudo yum install mysql-community-server
    
  3. Start Service

    sudo systemctl start mysqld
    sudo systemctl enable mysqld
    
  4. Get Temporary Password

    sudo grep 'temporary password' /var/log/mysqld.log
    

Installing on macOS

Using Homebrew

  1. Install Homebrew (if not installed)

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
  2. Install MySQL

    brew install mysql
    
  3. Start MySQL Service

    brew services start mysql
    
  4. Secure Installation

    mysql_secure_installation
    

Using DMG Package

  1. Download DMG Package Visit https://dev.mysql.com/downloads/mysql/ to download the macOS DMG package.

  2. Run Installer Double-click the PKG file and follow the wizard to complete installation.

  3. 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.