Overview
1. PreparationDownload the installation package: Go directly to the MySQL official website, find "Downloads" → "MySQL Community Server", and select the version for your system (Windows/Linux/Mac are all available). It's recommended to choose a stable version (such as the 8.0.x series) rather than the latest beta version.
Important notes: Avoid using Chinese characters or spaces in the installation path (for example, don't use "D:\Software\mysql", use "D:\mysql-8.0" instead). Otherwise, you may encounter errors later. On Windows, it's recommended to temporarily disable antivirus software to prevent it from blocking the installation process.
2. Installation Steps for Windows
Double-click the downloaded .msi installer. When the installation interface appears, select "Custom" (which is more flexible than the default installation).
Check "MySQL Server" (the core service). Other components, such as MySQL Workbench (a visual database tool), can be selected as needed. Then click "Next".
Choose the installation path, and remember this path (you'll need it later for configuration). Continue by clicking "Next".
On the "Type and Networking" page, the default port is 3306 (no need to change it; changing it may cause confusion). Leave other options as default and click "Next".
Set the root password: This step is very important! Make sure you remember the password (it's recommended to use a combination of letters and numbers, e.g., "mysql123456"). Don't make it too simple or forget it too quickly. After setting it, click "Next".
For the rest of the steps, just click "Next" → "Execute" and wait for the installation to complete. Finally, click "Finish".
3. Quick Installation on Linux (using Ubuntu as an example)
Open a terminal and update the package list first: sudo apt update
Install MySQL directly: sudo apt install mysql-server
After installation, start the service: sudo systemctl start mysql
Enable automatic startup on boot: sudo systemctl enable mysql
Initialize the password: sudo mysql_secure_installation. Follow the prompts to set the root password, and for other options, just press Enter to accept the defaults.
4. Key Configuration (to avoid login errors later)
Configure environment variables on Windows:
Right-click "This PC" → "Properties" → "Advanced system settings" → "Environment Variables"
In the "System variables" section, find "Path", click "Edit" → "New", and add the "bin" folder path under your MySQL installation directory (e.g., "D:\mysql-8.0\bin")
Click "OK" to save, then restart the command prompt (cmd) for the changes to take effect.
Verify the installation:
Open a command line (on Windows, press Win+R and type cmd; on Linux, open a terminal directly)
Enter the command: mysql -u root -p, then press Enter, and enter the password you set earlier.
If you see the "mysql>" prompt, the installation was successful!
