How to Set Up a MySQL Server on Windows

intro

Let’s learn what mysqld is and how to install the MySQL Server as a Windows service.

Tools used in the tutorial
Tool Description Link
Dbvisualizer DBVISUALIZER
TOP RATED DATABASE MANAGEMENT TOOL AND SQL CLIENT
MySQL logo MySQL
THE MYSQL DATABASE

The MySQL server, also known as MySQL daemon or mysqld, handles all MySQL database-related tasks, including data storage, user authentication, and security. Configuring the mysqld process to run in the background and setting up a MySQL server on Windows is not difficult. In this easy-to-follow guide, you will see how to do it.

Learn how to get started with mysqld on Windows!

Install MySQL Server on Windows

If you already have the MySQL server installed on your Windows machine, you can skip this section. Otherwise, follow this step-by-step tutorial and learn how to install MySQL on Windows.

1. Download the MySQL Installer

Visit the official site, and download the MySQL Community Installer for Windows.

The MySQL installers available in the official website
The MySQL installers available in the official website

The first package is a downloader for the installer, while the second is the full installer. Choose one of the two and click the "Download" button. Wait for the installer to be downloaded.

2. Install MySQL Server

Launch the mysql-installer-community-X.Y.Z.msi installer downloaded previously:

Selecting the "Server only" option
Selecting the "Server only" option

The “Server only” solution is what you need. However, if are a developer and need all MySQL features, select the “Developer Default” option.  Click “Next >” and follow the installation wizard. The MySQL installer will download the selected packages. Once done, click “Execute” to install them all.

The MySQL server has been installed correctly
The MySQL server has been installed correctly

3. Configure the MySQL Server

Keep clicking “Next >“ until you reach the configuration section below:

Configuring the MySQL server process
Configuring the MySQL server process

Here, you can configure the TCP port the MySQL server process will listen on. By default, the port for MySQL is 3306. Click “Next >“ and select the recommended option as the authentication method.

Selecting the most secure authentication method
Selecting the most secure authentication method

4. Configure the MySQL Root User

Again, click “Next >” and reach the “Account and Roles” section:

Setting up the "root" MySQL user
Setting up the "root" MySQL user

Here, you must specify a password for the MySQL root user. Use a strong password and store it in a safe place. You will need it soon.

Similarly, you can create other MySQL users with different roles through the “Add User” button.

5. Set up the MySQL server as a Windows service

Click on “Next >” and reach the  “Windows Service” configuration window:

Set up the MySQL server Windows service
Set up the MySQL server Windows service

Make sure that the option "Configure MySQL Server as a Windows service" is selected. This will register the MySQL server as a service on your Windows computer. By default, the MySQL installer suggests "MySQL80" as the Windows service name for the MySQL server. Do not change it.

If you do not plan to use the MySQL server frequently, uncheck the "Start MySQL server at system startup" option to save resources and speed up Windows startup.

6. Complete the MySQL Server Configuration

Keep following the installation wizard until you reach the “Apply Configuration” section. This is the last step.

Et voilà! The MySQL Server has been installed correctly!
Et voilà! The MySQL Server has been installed correctly!

Click “Execute” and wait for the installer to do its magic. When it is done, click “Finish” to finalize the MySQL server installation. Now, everything you need to do isto restart your PC.

Well done! You just set up the MySQL server as a Windows service!

Start the MySQL Service on Windows

Click on the Windows logo, type “Services,” and open the Windows Services app:

Note the "MySQL80" service
Note the "MySQL80" service

Here, you should find the “MySQL80” service set up previously. Click on the links on the left to stop/start, pause, or restart the service. If you right-click on the “MySQL80” service and select “Properties,” you can also change the startup type of the process:

Changing the startup option for MySQL80
Changing the startup option for MySQL80

Set it to “Automatic” to launch the MySQL server service on startup. Otherwise, prevent Windows from starting it by default with “Disabled.”

Fantastic! You now know how to start the MySQL server Windows service.

Connect to the Local MySQL Server

The best way to verify that the MySQL server is running as expected is to connect to it in a MySQL client, such as DbVisualizer. Let’s learn how to do it!

Download DbVisualier for free, install it, and launch the MySQL client with the most satisfied users on the market.

The DbVisualizer startup page
The DbVisualizer startup page

Select “Create a Database Connection” and click on the “Create a Connection” link on the right. In the popup window, type “mysql” and double-click the “MySQL 8” option.

Selecting the "MySQL 8" option
Selecting the "MySQL 8" option

You should now be seeing the following screen:

The MySQL connection window on DbVisualizer
The MySQL connection window on DbVisualizer

Here, you can configure a database connection to your MySQL 8 server. As you can see, DbVisualizer helps you by automatically populating some fields with useful predefined values. In detail, note that the “Database Server” and “Database Port” options are the correct ones so you do not have to insert them manually. Similarly, it is able to detect the right driver type for you.

In "Database Userid" field, enter "root" or the name of the MySQL server you want to use to connect. Then, specify the user's password in "Database Password." If you are using the root user, type the password you chose during installation. Finally, click the “Connect” button.

If everything went as expected, you should be seeing the connection message below:

Connecting to a MySQL server on DbVisualizer
Connecting to a MySQL server on DbVisualizer

Perfect! You just connected to your MySQL server. You can use explore the several features offered by the most complete MySQL database client on the market, including the explain plain to optimize your queries, native support for BLOB data, and much more! Also, note that you now have a new “MySQL 8” connection on the left tab.

Conclusion

In this article, you understood how to install the MySQL server on Windows. Specifically, you started from scratch and saw how to download the MySQL installer, use it to set up the MySQL server service on Windows, start it, and connect to DbVisualizer. This is a popular database client that comes with full assistance for MySQL, supporting all its data types and characterizing features. Download DbVisualizer for free!

FAQ about mysqld

What is mysqld?

mysqld is a multithreaded process that does most of the work in a MySQL database. In other words, it represents the MySQL server, which is responsible for storing and retrieving data, handling user authentication, and ensuring database security. The mysqld process generally runs in the background to ensure that MySQL is always available to process queries and perform database operations.

How to run MySQL from the command line on Windows?

To run MySQL from PowerShell, you must first add the MySQL executable files to the Windows environment variables. Follow the steps below to do so:

  1. Open the Windows Start menu and type "Environment Variables" in the search bar.
  2. Click on "Edit the system environment variables" from the search results.
  3. In the System Properties window, click on the "Environment Variables…" button.
  4. Under the System Variables section, scroll down and find the "Path" variable. Select it and click on "Edit".
  5. Click on "Browse…" and reach the "C:Program FilesMySQLMySQL Server 8.0bin" folder.
  6. Click on "OK" to add MySQL to the environment variables

Now, you can use the mysql command from the Windows terminal.

How to start the MySQL server from the Windows command line?

There are two ways to start the MySQL server from the Windows command line:

Method 1: Using the net start command.

  1. Right-click on the Windows logo and select “Terminal (Admin)” to launch PowerShell as an administrator.
  2. Start the MySQL server with the command below:
Copy
        
1 net start MySQL80

Note that the name of the MySQL service may differ based on the version of MySQL you installed.

If the server starts successfully, it should print a message that says "The MySQL service was started successfully."

Method 2: Using the mysqld command.

  1. Open the terminal as an administrator.
  2. Navigate to the MySQL bin directory:
Copy
        
1 cd "C:\Program Files\MySQL\MySQL Server 8.0\bin"
  1. Start the MySQL server with:

mysqld

When you start the MySQL server using this approach, you must keep the PowerShell window open. If you close the window, the server will stop.

How to stop the MySQL server from the Windows command line?

You can stop the MySQL server from the Windows command line with one of two methods:

Method 1: Using the net stop command

  1. Open PowerShell as an administrator.
  2. Stop the MySQL server with the command that follows:
Copy
        
1 net stop MySQL80

Keep in mind that the name of the MySQL server service may be different according to the version of MySQL you have.

If the server stops successfully, you should see the "The MySQL service was stopped successfully" message.

Method 2: Using the mysqladmin command

  1. Launch the terminal as an administrator.
  2. Mote to the MySQL bin directory with:
Copy
        
1 cd "C:\Program Files\MySQL\MySQL Server 8.0\bin"
  1. Type the command below to stop the MySQL server:
Copy
        
1 mysqladmin -u root -p shutdown

Enter your MySQL root password when prompted.

Note that when you try to stop the MySQL server using the mysqladmin command, you first need to make sure that all MySQL clients are closed before running the command. If there are any active MySQL connections, the command will fail and the server will not stop.

Where can MySQL logs be found on Windows?

In MySQL on Windows, the default location for log files is the “Data” directory. You can find this directory at "C:ProgramDataMySQLMySQL Server 8.0Data". These are the default log files used by MySQL on Windows:

  • Error log: ".err" (e.g., "DESKTOP-1234.err")
  • General query log: ".log" (e.g., "DESKTOP-1234.log")
  • Slow query log: "-slow.log" (e.g., "DESKTOP-1234-slow.log")

What is the difference between MySQL80 and mysqld?

On Windows, MySQL80 and mysqld are two different things in MySQL on Windows. "MySQL80" is the name of the MySQL service installed on your system. This service is used to start and stop the MySQL server. On the other hand, mysqld is the executable file that runs the MySQL server process. When you start the “MySQL80” service, "mysqld" is launched in the background.

Dbvis download link img
About the author
Antonello Zanini

Antonello is a software engineer, and often refers to himself as a technology bishop. His mission is to spread knowledge through writing.

The Table Icon
Sign up to receive The Table's roundup
More from the table
Title Author Tags Length Published
title

MySQL Nullable Columns: Everything You Need to Know

author Antonello Zanini tags MySQL 6 min 2024-12-03
title

A Complete Guide to the MySQL GROUP_CONCAT Function

author Antonello Zanini tags Data aggregation MySQL 8 min 2024-12-02
title

How and Why to Add an Index in SQL

author Lukas Vileikis tags MySQL POSTGRESQL Search SQL SQL SERVER 8 min 2024-11-28
title

MySQL 9.0 and the New EXPLAIN Features

author Lukas Vileikis tags MySQL SQL 9 min 2024-11-27
title

Massive SQL DELETE Operations and Database Purging Explained

author Lukas Vileikis tags DELETE SQL 4 min 2024-11-26
title

MySQL CAST: A Guide to the Data Conversion Function

author Antonello Zanini tags MySQL 3 min 2024-11-25
title

Postgres Create Array of Numbers: Complete Guide

author Lukas Vileikis tags POSTGRESQL SQL 7 min 2024-11-21
title

List of SQL Reserved Words in All Major Databases

author Antonello Zanini tags MySQL ORACLE POSTGRESQL SQL SQL SERVER 16 min 2024-11-20
title

A Beginner’s Guide to SQL & Relational Database Management Systems

author Leslie S. Gyamfi tags BEGINNER SQL 5 min 2024-11-19
title

SQL Variable: What It Is and How To Use It

author Antonello Zanini tags MySQL ORACLE POSTGRESQL SQL SQL SERVER 8 min 2024-11-18

The content provided on dbvis.com/thetable, including but not limited to code and examples, is intended for educational and informational purposes only. We do not make any warranties or representations of any kind. Read more here.

Cookie policy

We use cookies to ensure that we give you the best experience on our website. However you can change your cookie settings at any time in your browser settings. Please find our cookie policy here ↗