MariaDB Tutorial / Install MariaDB on Windows and Start the Server
On Windows, you can install MariaDB Server with an MSI package and run it as a Windows service. Record the service name, port, and administrator password, then verify both a client connection and a SQL query before starting the database exercises.
Check your computer before installing
This guide describes a fresh local learning setup on 64-bit Windows 11. Installing the MSI and changing services may require administrator privileges. If MariaDB or MySQL is already installed, distinguish upgrading an existing instance from creating an independent learning instance.
Read the current services and listening ports in PowerShell first. A service’s display name can differ from its actual Name, and an unfamiliar service name does not mean its data is disposable.
Get-Service | Where-Object { $_.Name -match 'MariaDB|MySQL' }
Get-NetTCPConnection -State Listen -LocalPort 3306 -ErrorAction SilentlyContinue
On a computer with no existing server, an empty result is normal. If a server is found, do not stop it or reuse its data directory without understanding its purpose. A separate instance needs a different service name and, if the port is occupied, a different port. Adjust every connection command to the port you actually choose.
Download the MSI and choose its components
- Use the official MariaDB download page to choose a supported stable MariaDB Server release and its Windows x64 MSI package. Preview builds are not the baseline for this beginner setup.
- Run the MSI, review the license, and continue to Custom Setup. Ensure the server, client, and database-instance components are selected.
- Record the installation path and data directory. The examples use
C:\Program Files\MariaDB 12.3\; substitute your actual path if it differs. A graphical tool such as HeidiSQL is optional for these command-line exercises.
Installer labels and screen layouts can change between versions. The official Windows MSI installation guide explains the database-instance options. Do not choose an existing-instance upgrade merely because that option appears in the wizard.
Set the service, administrator, and connection options
| Setting | Choice for a local learning instance |
|---|---|
| Root password | Choose a strong password and keep it securely; root is the database administrator |
| Remote root access | Leave disabled for this local exercise |
| Anonymous account | Leave disabled |
| Windows service | Install as a service and record its actual service name |
| TCP port | Use 3306 if it is free, or record a separate port |
| Character-set option | An installer UTF-8 option does not replace explicit utf8mb4 database settings |
The administrator password is not your Windows login password. You will create a separate account for the SQL exercises after checking the server. Local access through 127.0.0.1 does not require opening the server’s port to external networks. Complete the installation and note any error rather than assuming the server started successfully.
Start the service and verify an administrator connection
If the service is named MariaDB, use these PowerShell commands. Replace that name if you chose another. Starting a service may require an administrator PowerShell window.
Get-Service -Name MariaDB Start-Service -Name MariaDB Get-Service -Name MariaDB
The final service status should be Running. The MariaDB Command Prompt supplied by an installation may already include the client directory in its path. In ordinary PowerShell, an explicit executable path avoids that dependency:
& "C:\Program Files\MariaDB 12.3\bin\mariadb.exe" --protocol=tcp --host=127.0.0.1 --port=3306 --user=root --password --default-character-set=utf8mb4
PowerShell’s & invokes the quoted executable. Use your actual path and port. The --password option without a value asks for the password interactively, avoiding a password written into the command. Once connected, run:
SELECT VERSION() AS server_version; SELECT 1 + 1 AS result;
The server should return its version and a calculation result of 2. A client that opens successfully without connecting is not sufficient evidence that the server works.
Create an account limited to the practice database
Use root for setup, then switch to course_user for learning. First check whether that name already exists:
SELECT User, Host FROM mysql.user WHERE User = 'course_user';
If an account already exists, inspect its host and purpose rather than deleting or recreating it blindly. For a fresh tutorial account, replace the password placeholder below with your own strong password and run these statements as the administrator:
CREATE USER 'course_user'@'127.0.0.1' IDENTIFIED BY 'CHANGE_THIS_TO_YOUR_OWN_PASSWORD'; GRANT ALL PRIVILEGES ON shopcourse.* TO 'course_user'@'127.0.0.1'; SHOW GRANTS FOR 'course_user'@'127.0.0.1';
The account name includes both a user and a host. These examples deliberately connect over TCP to 127.0.0.1 and grant privileges to that host account. The grant covers shopcourse.*, so the account can work within the practice database, including creating it, without global privileges or permission to grant privileges to others. It is valid to grant this scope before the database exists. A production application would normally receive a narrower set of permissions according to its work. See the CREATE USER reference and GRANT reference for the rules.
Disconnect with EXIT; and reconnect from your terminal:
mariadb --protocol=tcp --host=127.0.0.1 --port=3306 --user=course_user --password --default-character-set=utf8mb4 --abort-source-on-error
SELECT CURRENT_USER() AS privilege_account;
The privilege account should be course_user@127.0.0.1. The command-line client and SQL-file guide explains the options and subsequent checks. CREATE USER and GRANT take effect without a manual FLUSH PRIVILEGES for this procedure.
Diagnose common installation and connection problems
- Service will not start: verify its name, check for a port conflict, and read the instance’s error log. Preserve the data directory.
- Client command not found: use the actual full executable path or the installation’s MariaDB Command Prompt.
- Cannot connect: check whether the intended service is running and whether the command’s host and port match it.
- Access denied: verify the password and the database account’s host. Authentication failure is different from a stopped server.
Before changing a learning instance’s my.ini, save the original file and record its location. Change one setting, restart that instance, and verify the result. Restore the saved file if the change prevents startup. Stopping a service, uninstalling software, and deleting database files are separate actions; deleting data is not a routine login fix.






