Introduction
MySQL is an open-source relational database management system (RDBMS). It stores, manages, and retrieves data using Structured Query Language (SQL). Here, the data is stored in rows and columns in tables, and applications connect to a database server for data operations, and it supports complex queries and transactions.
Let’s dive in to understand how to setup MySQL and create a database in MySQL:
Step-by-Step Guide
1. Go to https://dev.mysql.com/downloads/installer and click on Download next to Windows (x86, 32-bit), MSI Installer (mysql-installer-community-8.0.39.0.msi)—this works for 64-bit also.
2. A new window opens; click on No thanks; just start my download to start downloading MySQL.
3. On the right-hand corner, click on Open File under Downloads.
or click on a folder icon and double-click on mysql-installer-community-8.0.39.0 to start the installation.
4. The MySQL Installer set-up wizard opens.
- In the Choosing Setup Type window, select Custom and click Next.
Note: By selecting the custom option, we can manually select the products that should be installed on the computer.
5. In the Select Products window,
Under Available products,
- Click on the + icon next to MySQL Servers; under that, select MySQL Server 8.0.39-x64 and click on the green arrow button.
- Click on the + icon next to Applications, select MySQL Workbench 8.0.38-x64, and then click on the green arrow button
- Click on the + icon next to MySQL Shell, select MySQL Shell 8.0.38-x64, and then click on the green arrow button.
- After adding the selected products, click on Next.
6. In the installation window, you can see the products that are to be installed.
- Click on Execute.
- Once the installation is complete, you can see the screen below. Click on Next.
7. In the Product Configuration window, click on Next.
8. In the Type and Networking window, you can see Server Configuration Type, Connectivity, and Advanced Configuration.
- Click on Next
9. In the Authentication Method window, select Use Strong Password Encryption for Authentication (Recommended).
- Click on Next.
10. In the Accounts and Roles window, enter the strong password in MySQL Root Password and Repeat Password.
- Click on Next.
11. In Windows Service,
- Check the box next to Configure MySQL Server as a Windows Service.
- Check the box next to Start MySQL Server at System Startup.
- Select the Standard System Account.
- Click on Next.
12. In the Server File Permissions window,
- Select Yes, and grant full access to the user running the Windows Service (if applicable) and the administrator group only. Other users and groups will not have access.
- Click Next.
13. In the Apply Configuration windows, click Execute.
- Once the configuration is successful, click on Finish.
14. In the Product Configuration window, click Next.
15. In the Installation Complete window,
- Check the box next to Start MySQL Workbench after setup.
- Check the box next to Start MySQL Shell after setup.
- Click Finish.
16. Once we click on Finish, it will navigate to the command prompt showing the installation of MySQL Shell 8.0.38.
After a few seconds, it will navigate to MySQL Workbench. Here, click on Local instance MySQL8.0
17. Here,
- Enter the Password that you already mentioned in step 10 (Accounts and Roles window)
- Check the box next to Save Password in the vault.
- Click on OK.
18. Now, you are in MySQL Workbench.
- Here, you create a new schema by clicking on the Create new schema icon. Enter the name and click on Apply.
Note: Here, the name of the schema is employee.
- A new window opens showing the schema that was created, and you can click on Apply.
- Click on Finish.
- Now, in the workbench, create tables in the schema.
Click on Schemas in the bottom left corner of the window. It will show you the schemas that were created.
sys is the default schema.
Click on the drop-down menu next to your schema_name (ex: employee), and you can see tables, views, stored procedures, and functions. You can select any of them according to your requirements and fill in the information.
Note: You can also create tables using the table icon in the menu bar.
19. We must add the path to MySQL in Environment Variables. To do so,
- Go to the Windows search bar and type environment variables.
- Select Edit the system environment variables
- In the System Properties window, click on Environment Variables.
- The Environment Variables window opens.
- Under System Variables, double-click on Path (which is highlighted) and click OK.
- Click on New, add the new path, and click on OK.
- After this, click OK in the Environment Variables window and
- Click OK under the System Properties window.
20. Open the command prompt by typing cmd in the Windows search bar.
Here, verify the installation of MySQL by running the below command.
Command: mysql --version
If it is successfully installed, you can see the message “MySQL Ver 8.0.39 for Win64 on x86_64 (MySQL Community Server, GPL).”
21. By running the below command, you can log in to MySQL Server.
Command: mysql -u root -p
After running this command, you will be prompted to enter a password (which is given in step 10: Accounts and Roles window).
You can also see your MySQL connection ID (here it is 15).
22. You can see if there are any databases by default by running the below command.
Command: show databases;
Note: You can see there are no databases at present.
23. You can create a database by running the command below.
Command: create database d; create database d1;
- Now, run the below command to verify if the databases are added or not.
Command: show databases;
Now, you can see that ‘d’ and ‘d1’ databases have been added.
Frequently Asked Questions (FAQs)
Q1. What is MySQL used for?
Answer: MySQL is a popular relational database management system (RDBMS) used for managing and organizing data. It is commonly used in web applications, data warehousing, and business applications to store, retrieve, and manipulate data.
Q2. What is SQL vs. MySQL?
Answer: SQL (Structured Query Language) is a standard language used for querying and managing databases. It provides commands to perform various operations on data, such as querying, updating, and deleting records. MySQL, on the other hand, is a specific relational database management system that uses SQL as its query language. Essentially, SQL is the language you use, and MySQL is the software that processes SQL commands.
Q3. Is MySQL a coding language?
Answer: No, MySQL is not a coding language. It is a database management system that uses SQL, a query language, to interact with databases. MySQL provides a platform where SQL commands are executed to manage and manipulate data.
Q4. What is MySQL’s role?
Answer: MySQL’s role is to store, manage, and retrieve data efficiently. It provides a structured way to store data in tables, supports complex queries to access the data, and ensures data integrity and security. It is widely used in various applications, from small websites to large enterprise systems.
Q5. Is MySQL easy to learn?
Answer: MySQL is generally considered to be beginner-friendly, especially if you are familiar with SQL. The basic concepts and commands are relatively straightforward to learn, but mastering advanced features and optimizations may take more time and experience.
Q6. Which software is used for MySQL?
Answer: To interact with MySQL databases, you can use various software tools, such as:
- MySQL Workbench: A graphical user interface (GUI) for designing, managing, and administering MySQL databases.
- phpMyAdmin: A web-based tool for managing MySQL databases.
- MySQL Command Line Client: A command-line interface for executing SQL commands.
- DBeaver: A universal database tool that supports MySQL and other database systems.
Ready to streamline your technical writing needs? At The Scribe, we offer a range of expertly curated writing services to enhance your documentation and content. Whether you need technical manuals, website content, or comprehensive business proposals, our skilled writers are here to help. Contact us today to see how we can support your web development projects with clear, impactful documentation!