In this step by step guide, we are answering the question of how to install MySQL on Windows, specifically Windows 10. We are starting with downloading MySQL installer until we are able to run a basic query on the database.
Here is the guide PDF file for download: How to install MySQL on windows 10 (web) (1629 downloads )
Disclaimer:
- MySQL is a trademark of Oracle.
- The images from the installation are copyright © by Oracle.
- Turn on windows feature screen is copyright © by Microsoft.
- Windows 10 is copyright © by Microsoft.
Step 1 – downloading MySQL:
The first step is to download MySQL from the internet. Open your web browser and navigate to the following URL: Download MySQL
Once you press the download button. You will be redirected to the following URL: https://dev.mysql.com/downloads/file/?id=497106
Please note, the ID might be different.
If you have an account you can log in by pressing the login button. If you want you can create an account by pressing the Sign-Up button and fill the needed information.
Below it there is a link for the download. You can use this direct link to start download the MySQL installer.
Right-click on this link show the direct download URL, here is what I get:
https://dev.mysql.com/get/Downloads/MySQLInstaller/mysql-installer-community-8.0.21.0.msi
Please note that it may not work once the version will be change – in my case it downloads version 8.0.21.0.
Once the download is done, you can go to the folder that the file was saved and run it. The default download folder should be Downloads. That is unless you change your download folder or select a different download location.
Step2 – Installing MySQL on Windows 10:
To start the installation, right-click the file and select install. You will see the following screen at the start of the installation.
If you see the User Access Control screen please allow it by pressing yes. If everything went well you will see the following screen:
In this guide, we are selecting the full option. This will install everything, here is the text from the description box:
Installs all of the products available in this catalog including MySQL Server, MySQL Shell, MySQL Router, MySQL Workbench, MySQL Connectors, documentation, samples, and examples, and much more.
You might have to install some requirements, that MySQL needs before the installation.
In my case, the only one that is missing is the Microsoft Visual C++ 2019 Redistributable Package. MySQL installation can install it automatically.
You may need to install another component that MySQL requires. If the requirement is not part of the installation you will have to install it, by downloading it from the internet or by using the Turn Windows Features on or off.
To continue our installation, I selected the first one and press the Execute button.
The inhalation will start to download the pre-requirement and install them. You can see the status changes.
Once it done, the screen will change and you can press the next button to continue:
Once pressing the next button the install screen appears and you can press the Execute to start the installation:
Let the installation process run, it may take some time…
Once everything is complete you can press the Next button to continue.
Step3 – Configuration:
Once you press the next button on the above step you will get a screen that is related to configuration.
We are not configuring a cluster in this guide, maybe in the future, I will create a guide to configure a cluster with MySQL. Make sure you selected the Standalone MySQL server and press Next.
If you need to change the default port it will use, you can do it here. Also, for this guide, I am using the Development Computer option as this is my dev device and I will use it to debug the site, apps, and query that I will develop. You can select the Server option if you don’t need a development environment.
I did mark the Show advanced and Logging option for some more configuration options.
For the authentication method, I am using the strong password option that is recommended by the installation.
Set a strong password, and if you need to add more users to MySQL you can do it using the Add User button.
MySQL is configured to run as a service. It is adding another service to your running service. Adding it as a service will let MySQL run even if no user is currently logon in the system.
You can leave the log names as-is unless you want to give it another name.
And also the Advanced options.
The next step is to apply the configuration that we did:
Once this process is done your MySQL server is installed and running. Press Finish to finish the installation and move on to the configuration part.
Step 4 – MySQL product configuration continues:
As we are not configuring a cluster, we can skip the router configuration. Just press the Finish button.
Next step is the connection to your server, here we can verify that we can connect to our MySQL server
Use the password we configure during the installation.
If everything is ok, we can continue by pressing Next. In the next screen press the Execute button to apply the configuration.
You will see small green V marks. That indicates the installation was successful.
Press the Finish button to go to the next step.
The next step is related to the installation of the sample and examples. Press the next button wait for it to finish.
Once it finishes you will see the following screen. Live both of the option marks and finish the installation by pressing the finish button.
Step 5 – We have a database lets have fun:
Once you press the Finish button and if you select both option 2 windows will be open.
One for a command-line interface to the database:
And another one, a GUI based interface:
BTW, the following was added to your Menu:
And here is our MySQL service, running:
Step 6 – MySQL the command line:
When using the command line interface one of the first commands you need to know is \help using that command will show you help about other commands.
Connecting to the database:
To connect the database, you can use the MySQL command. Type MySQL and press enter.
Next, you need to connect to the database, run the following command:
\connect –mx root@localhost
It will prompt you for the password, insert the password and press enter. Use the password we enter during the installation process of MySQL.
Create new database
To create a new database, we need to run the following command:
\show query create database openport
The above command tells MySQL to create a new database name openport. After running that command you will have a new ready to use, an empty, database named openport.
Once the database is ready, we need to tell MySQL that we want to use this database. Run the following command:
\show query use openport
Now we are using the openport database.
Adding table to the database
To add a table to the database, you need first to think about what you want to store in that table and to design it. For the use of our guide, we will create a table to store basic information about URL.
The table will contain the following URL information:
- Link – A link in the site, re: https://openport.net
- Added – The date we added this link.
- Modify – The date that link changed, or removed.
- Status – Current status of the link, can be 1-active, 2-disable, 3-deleted.
Let’s run the command to create our table:
\show query create table url (link VARCHAR(100), added DATE, modify DATE, status int)
- VARCHAR – mean this will hold a string value.
- DATE – mean this will hold a date.
- INT – Mean this will hold a number.
Cool, we have a table that we can now start to add some date.
Adding some data to the table
I am using the following command to add one line of data to our table.
\show query insert into url (link, added,modify,status) values (‘https://openport.net’, NOW(),NOW(),1)
Once running this command, a new line will be created and added to the database with the following information, the link, the dates, and 1 as the active status.
Show the table data:
OK, now that we added the data into our table let see it. Use the following command to see the data we have in our table:
\show query select * from url
After running this command, you will see an output text table with one line in it. The line we insert into the database.
Here is an image that shows the above steps:
Some more useful commands:
This command will show you the list of databases that you have:
\show query show databases
The following command will show you all the tables you have in the currently selected database:
\show query show tables
This command will show you information about the table name url:
\show query describe url
Step 7 – MySQL the GUI way:
Press on the MySQL Connection area, a Connect to MySQL dialog will be open, type in your password and press OK.
The following windows will be open:
Now that we are connected to the database lets do what we do in the command line but from the GUI.
Create a new database:
Press the add new schema icon, then give our database a name. After that press the apply button.
A new window will be open, that will show you the query it is about to run to create that database.
Press apply to continue.
And then press finish to close the database creation wizard.
Now we have a new database.
Create a new table:
Let’s add a new table to the database, we will use the same information as we did for the table in the command line section.
Expend the openport database that we created.
Right-click on tables and select Create table.
Set the table name. Press the Column name to start adding a new column to our table.
The first column is a running index, we did not add it in the command line version.
The PK, NN, UQ, AI are optional options, and you can set a default value to the columns.
In our case, the first index (idurl) is a primary key (PK), not null (empty) (NN), unique (UQ), and with a default value of 1001. This means that will Autoincrement (AI) with each newly added URL to the table.
I also set our status with a default value of 1.
Press Apply.
An SQL query script window will appear, it will show you the query it is about to run to create our table. Press Apply to continue. Now we have our table ready.
Add data to that table:
Let’s add data to our table. One of the options to add data to our table is by expending our table, and right-click on columns->Send to SQL Editor->Insert Statement.
Insert, in SQL, is the command to add (insert) data to the table.
This method allows us to run a query to add data, you will need to type it into the query.
Another method is using the UI. You can do it by double click on the following table like icon near our table name:
This will open a window that contains a grid that you can use to add new data to the table.
Fill in the needed information and press Apply.
And we have new data in our table.
TIP:
Our table requires a date parameter, this should be the current date.
To get the current date, you can run a query – SELECT NOW()
Type it in the above text area, after the SELECT. Select it with your mouse (mark). Press the lightning icon for running only the selected query.
Show table information:
Now we need to see the new data that we insert into our table to do that we can run the query we have in the text box. We can also reopen it by pressing the table button and it will show it to us:
Cool, we have data in our table.
The end?
Well, in this guide we download MySQL from the internet, run through the installation process, configure it to run. Created a new database, add data to the database, and see it. This is the end of this guide, but it is definitely not the end of your learning, you can now go deeper into MySQL databases, by learning to write queries, learning how to manage the database, backup, procedure and more.
I do hope that this guide gives you the information you needed, regarding how to install MySQL on Windows 10.
If you have any questions or comments, you are more than welcome to contact us using our contact page.
References:
- Create Tables – https://dev.mysql.com/doc/refman/8.0/en/creating-tables.html
- INSERT Multiple rows – https://www.mysqltutorial.org/mysql-insert-multiple-rows/
- MySQL community installer – https://dev.mysql.com/downloads/installer/
2 thoughts on “How to install MySQL on windows 10”