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 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:
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.
3. Configure the MySQL Server
Keep clicking “Next >“ until you reach the configuration section below:
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.
4. Configure the MySQL Root User
Again, click “Next >” and reach the “Account and Roles” section:
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:
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.
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:
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:
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.
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.
You should now be seeing the following screen:
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:
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:
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
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
cd "C:\Program Files\MySQL\MySQL Server 8.0\bin"
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
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
cd "C:\Program Files\MySQL\MySQL Server 8.0\bin"
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:
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.