> For the complete documentation index, see [llms.txt](https://docs.ititanhosting.ro/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ititanhosting.ro/docs/english/vps/windows/how-to-install-mysql-on-windows-server.md).

# How to install MySQL on Windows Server

MySQL is one of the most popular database systems. It works well with web applications, game servers, and CMS platforms like WordPress. Here is how to get it running on your Windows VPS.

### Step 1: Download the MySQL Installer

1. Open your browser on the VPS
2. Go to [dev.mysql.com/downloads/installer](https://dev.mysql.com/downloads/installer/)
3. Download the **MySQL Installer for Windows** (the web version is fine, it downloads what it needs)

### Step 2: Run the installer

1. Double-click the downloaded file
2. Accept the license terms
3. Choose **Developer Default** if you want MySQL Workbench included, or **Server only** for a minimal setup
4. Click **Next** and then **Execute** to download the required packages

### Step 3: Configure MySQL Server

After the packages install, the configuration wizard opens:

1. **Type and Networking:** Keep the defaults (Standalone MySQL Server, TCP/IP on port 3306)
2. **Authentication Method:** Choose **Use Strong Password Encryption**
3. **Accounts and Roles:** Set a strong **root password**. Write it down, you will need it
4. **Windows Service:** Keep **Configure as Windows Service** checked. Set it to start automatically
5. Click **Next** and then **Execute** to apply the configuration

### Step 4: Verify the installation

Open Command Prompt or PowerShell:

```powershell
mysql --version
```

You should see the MySQL version. Now test logging in:

```powershell
mysql -u root -p
```

Enter the root password. If you get the `mysql>` prompt, everything works.

Type `exit` to leave the MySQL prompt.

### Step 5: Create a database and user

From the MySQL prompt, create a database for your application:

```sql
CREATE DATABASE myapp_db;

CREATE USER 'myapp_user'@'localhost' IDENTIFIED BY 'yourpassword';

GRANT ALL PRIVILEGES ON myapp_db.* TO 'myapp_user'@'localhost';

FLUSH PRIVILEGES;

EXIT;
```

### Step 6: Allow remote connections (optional)

If you need to connect to MySQL from another machine:

1. Open the MySQL configuration file:

```
C:\ProgramData\MySQL\MySQL Server X.Y\my.ini
```

2. Find the line:

```
bind-address = 127.0.0.1
```

3. Change it to:

```
bind-address = 0.0.0.0
```

4. Save the file and restart MySQL:

```powershell
net stop MySQL80
net start MySQL80
```

5. Grant remote access to your user:

```sql
CREATE USER 'myapp_user'@'%' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON myapp_db.* TO 'myapp_user'@'%';
FLUSH PRIVILEGES;
```

6. Open port 3306 in Windows Firewall:

```powershell
netsh advfirewall firewall add rule name="MySQL Port 3306" dir=in action=allow protocol=TCP localport=3306
```

For better security, replace `'%'` with a specific IP address.

### Step 7: Install MySQL Workbench (optional)

MySQL Workbench gives you a graphical interface for managing databases. It was included if you chose Developer Default. Open it from the Start menu, connect to `localhost` using the root account, and you can manage everything visually.

### Using MySQL from PowerShell

Export a database:

```powershell
mysqldump -u root -p myapp_db > C:\backup\myapp_db.sql
```

Import a database:

```powershell
mysql -u root -p myapp_db < C:\backup\myapp_db.sql
```

### Common issues

**"MySQL service does not start"** Open the Windows Event Viewer and check the Application logs for MySQL error messages. Common causes include port conflicts or incorrect configuration.

**"Access denied"** Make sure you are using the correct username and password. If you forgot the root password, you can reset it by starting MySQL with the `--skip-grant-tables` option.

**Port 3306 not reachable** Check that the Windows Firewall allows inbound TCP connections on port 3306. Also check with your hosting provider that the port is not blocked at the network level.

### Useful commands

```powershell
# Start MySQL service
net start MySQL80

# Stop MySQL service
net stop MySQL80

# Restart MySQL service
net restart MySQL80

# Check MySQL service status
sc query MySQL80
```

### Conclusion

MySQL is installed and ready. You now have a full database server running on your Windows VPS, ready for web applications, game servers, or any other project that needs a database.
