Install MySQL on Windows with winget and Connect It to DBeaver
Installing MySQL on Windows can feel confusing when you are new to databases.
There are installers, services, passwords, environment variables, and database tools to think about.
The good news is that Windows has a fast package manager called winget, and it can install MySQL with just a few commands.
In this tutorial, you will learn how to:
- Install MySQL Community Server using
winget - Add MySQL to your terminal path
- Initialize the MySQL data directory
- Install MySQL as a Windows service
- Start MySQL automatically
- Reset the root password
- Install DBeaver
- Connect DBeaver to your local MySQL server
What You Are Installing
Before running commands, it helps to understand the tools involved.
MySQL Community Server
MySQL Community Server is the actual database server.
It stores your databases, tables, users, and data.
When people say "install MySQL", this is usually the main thing they mean.
winget
winget is the Windows Package Manager.
It lets you install software from PowerShell or Windows Terminal using commands like this:
winget install Oracle.MySQL
Instead of downloading installers manually, winget finds and installs the package for you.
DBeaver
DBeaver is a graphical database tool.
It lets you connect to MySQL, view tables, run SQL queries, and manage your database visually.
It is beginner-friendly and works with many databases, including MySQL, PostgreSQL, SQLite, SQL Server, and more.
Prerequisites
Before starting, make sure you have:
- Windows 10 or Windows 11
- Administrator access
- PowerShell or Windows Terminal
- Internet access
wingetinstalled
You can check if winget is available by running:
winget --version
If you see a version number, you are ready.
Step 1: Open PowerShell as Administrator
You need Administrator permissions because MySQL will be installed as a Windows service.
To open PowerShell as Administrator:
- Right-click the Start button.
- Click Terminal (Admin) or Windows PowerShell (Admin).
- Accept the User Account Control prompt.
All commands in the MySQL setup section should be run from this Administrator PowerShell window.
Step 2: Install MySQL Using winget
Run this command:
winget install Oracle.MySQL
This installs the official MySQL Community Server package.
After installation finishes, MySQL is installed on your computer, but it may not yet be ready to use from PowerShell.
Step 3: Add MySQL to Your PowerShell Path
The MySQL command-line tools are usually installed inside the MySQL installation folder.
For MySQL 8.4, the path is commonly:
C:\Program Files\MySQL\MySQL Server 8.4\bin
To make MySQL commands available in your current PowerShell session, run:
$env:Path += ";C:\Program Files\MySQL\MySQL Server 8.4\bin"
This lets you use commands like:
mysql
mysqld
Important Note About the Path
This command only updates the path for the current PowerShell window.
If you close PowerShell and open it again, you may need to run it again unless MySQL was added permanently to your system environment variables.
To test if the path works, run:
mysqld --version
If you see MySQL version information, the command is working.
Step 4: Initialize the MySQL Data Directory
MySQL needs a data directory before it can run.
The data directory stores:
- Database files
- System tables
- User accounts
- Permissions
- Server metadata
Run this command in Administrator PowerShell:
mysqld --initialize --console
This initializes MySQL and generates a temporary password for the root user.
Look carefully at the output.
Near the end, you should see a line similar to this:
A temporary password is generated for root@localhost: Abc123xyz!
Copy the temporary password.
You will need it when logging in for the first time.
Step 5: Install MySQL as a Windows Service
A Windows service allows MySQL to run in the background.
This means you do not have to manually start the database server every time from the terminal.
Run:
mysqld --install
This registers MySQL as a Windows service.
The service name is usually:
mysql
Step 6: Start the MySQL Service
Now start MySQL:
Start-Service -Name "mysql"
To check if it is running, you can use:
Get-Service -Name "mysql"
You should see a status like:
Running
Step 7: Make MySQL Start Automatically
To make MySQL start automatically when Windows starts, run:
Set-Service -Name "mysql" -StartupType Automatic
This is useful for development because your database server will be available after restarting your computer.
Step 8: Log In to MySQL as root
Now connect to MySQL using the command-line client:
mysql -u root -p
PowerShell will ask for a password.
Paste the temporary password you copied from the initialization step.
You may not see characters appear while typing or pasting the password. That is normal.
Press Enter.
If the login succeeds, you will see the MySQL prompt:
mysql>
Step 9: Change the root Password
The temporary password must be replaced before you can use MySQL normally.
At the mysql> prompt, run:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'YourNewPassword';
FLUSH PRIVILEGES;
EXIT;
Replace YourNewPassword with a strong password.
Example:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'SecureRootPassword123!';
FLUSH PRIVILEGES;
EXIT;
What These Commands Do
The first command changes the root password:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'SecureRootPassword123!';
The second command reloads MySQL permissions:
FLUSH PRIVILEGES;
The third command exits MySQL:
EXIT;
Step 10: Create a Database and User for Your App
Using the root account for everyday development is not recommended.
A better approach is to create a separate database user.
Log back in as root:
mysql -u root -p
Then run:
CREATE DATABASE pickup_app;
CREATE USER 'pickup_user'@'localhost' IDENTIFIED BY 'SecurePassword123!';
GRANT ALL PRIVILEGES ON pickup_app.* TO 'pickup_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
This creates:
- A database called
pickup_app - A user called
pickup_user - A password for that user
- Permissions for that user to access only the
pickup_appdatabase
Step 11: Install DBeaver Using winget
Now install DBeaver:
winget install dbeaver.dbeaver
After installation finishes, open DBeaver from the Windows Start Menu.
Step 12: Create a New MySQL Connection in DBeaver
In DBeaver:
- Click the New Database Connection button.
- Choose MySQL.
- Click Next.
DBeaver may ask to download the MySQL driver.
Click Download.
The driver allows DBeaver to communicate with MySQL.
Step 13: Enter the MySQL Connection Settings
Fill in the connection form like this:
Host: localhost
Port: 3306
Database: pickup_app
Username: pickup_user
Password: SecurePassword123!
These values mean:
localhostmeans MySQL is running on your own computer.3306is the default MySQL port.pickup_appis the database you created.pickup_useris the user you created.SecurePassword123!is the password for that user.
Click Test Connection.
If everything is correct, DBeaver should show a success message.
Then click Finish.
Step 14: Test Your Database in DBeaver
After connecting, open a new SQL editor in DBeaver.
Run this test query:
SELECT DATABASE();
You should see:
pickup_app
Now create a simple table:
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(150) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
Insert a test row:
INSERT INTO users (name, email)
VALUES ('Alex Carter', 'alex@example.com');
View the data:
SELECT * FROM users;
You should see the user record in the results grid.
Common Problems and Fixes
Problem: mysqld is not recognized
This means PowerShell cannot find the MySQL binaries.
Run:
$env:Path += ";C:\Program Files\MySQL\MySQL Server 8.4\bin"
Then try again:
mysqld --version
If your MySQL version folder is different, update the path.
For example:
C:\Program Files\MySQL\MySQL Server 8.0\bin
Problem: Temporary password was missed
If you missed the temporary password during initialization, scroll up in the PowerShell output.
Look for:
A temporary password is generated for root@localhost
If you cannot find it, you may need to remove the initialized data directory and initialize again. Be careful because this can delete database files.
Problem: MySQL service will not start
Check the service status:
Get-Service -Name "mysql"
Try starting it again:
Start-Service -Name "mysql"
If it still fails, check whether MySQL was already installed before or whether another MySQL service is using the same port.
Problem: DBeaver cannot connect
Check these items:
- Is the MySQL service running?
- Is the host set to
localhost? - Is the port set to
3306? - Is the username correct?
- Is the password correct?
- Did you create the database?
- Did you grant privileges to the user?
You can test the same user from PowerShell:
mysql -u pickup_user -p pickup_app
Then enter:
SecurePassword123!
If this works in PowerShell, DBeaver should also be able to connect.
Useful MySQL Commands
Show databases:
SHOW DATABASES;
Use a database:
USE pickup_app;
Show tables:
SHOW TABLES;
Describe a table:
DESCRIBE users;
Show current user:
SELECT USER();
Show current database:
SELECT DATABASE();
Exit MySQL:
EXIT;
Full Command Summary
Here is the complete setup in one place.
Install MySQL:
winget install Oracle.MySQL
Add MySQL to the current PowerShell path:
$env:Path += ";C:\Program Files\MySQL\MySQL Server 8.4\bin"
Initialize MySQL:
mysqld --initialize --console
Install MySQL as a service:
mysqld --install
Start the service:
Start-Service -Name "mysql"
Enable automatic startup:
Set-Service -Name "mysql" -StartupType Automatic
Log in as root:
mysql -u root -p
Change the root password:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'SecureRootPassword123!';
FLUSH PRIVILEGES;
EXIT;
Create an app database and user:
CREATE DATABASE pickup_app;
CREATE USER 'pickup_user'@'localhost' IDENTIFIED BY 'SecurePassword123!';
GRANT ALL PRIVILEGES ON pickup_app.* TO 'pickup_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Install DBeaver:
winget install dbeaver.dbeaver
Key Considerations
- Always run the MySQL service setup commands as Administrator.
- Copy the temporary root password immediately after running
mysqld --initialize --console. - Do not use the root account for normal application development.
- Create a separate database user for each project.
- Use a strong password instead of example passwords in real projects.
- Make sure MySQL is running before trying to connect from DBeaver.
- The default MySQL port is
3306. - If your MySQL installation folder is different, update the path command.
Recommendations
For beginners, this is a good local development setup:
- Use
rootonly for administration. - Use a project-specific user such as
pickup_user. - Use a project-specific database such as
pickup_app. - Use DBeaver for browsing tables and running SQL queries.
- Keep your SQL scripts saved in your project folder.
- Use clear database names that match your application.
- Avoid storing real production data on your local development database.
A simple naming pattern is:
app_name
app_name_user
Example:
pickup_app
pickup_user
This makes it easier to remember which user belongs to which database.
Conclusion
You have now installed MySQL on Windows using winget, initialized the server, installed it as a Windows service, changed the root password, created a project database, and connected to it using DBeaver.
This setup is great for learning SQL, building local applications, and testing database-driven projects.
Once DBeaver is connected, you can create tables, insert records, run queries, and manage your database visually without needing to remember every command.