Student Lab Workbook: Installing MySQL Server and Workbench on Windows 10 and 11
This guide will assist you in installing MySQL Server and MySQL Workbench on a Windows 10 and 11 system, along with guiding you through running basic SQL commands to create and populate databases and tables.
October 11 Class:
We will setup an Apache Web Server and use PHP to build a front end client for the MySQL Server with HTML forms.
**Prerequisite: Microsoft Visual C++ 2019 Redistributable Package**
MySQL 8.0 Server requires the Microsoft Visual C++ 2019 Redistributable Package to run on Windows platforms. You can download it from the [Microsoft Download Center](https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-160).
**Section 1: Installing MySQL Server on Windows 10 and 11**
2. DONE: Start Installation:** After downloading, open the installer (.msi file). You might be prompted for administrative rights, grant them.
3. **Setup Type:** Select the setup type you prefer. For a basic installation, go for "Server Only" or "Developer Default." Continue by clicking "Next."
4. **Installation:** Review the products to be installed and click on "Execute" to start the installation.
5. **Product Configuration:** Proceed with product configuration that includes configuring the server type, connectivity, authentication method, service details, etc.
6. **Root password:** During the configuration process, set a root password for your MySQL Server essential for server login.
7. **Finish Installation:** Finish the configuration, and on the final screen, click on "Finish."
Now you can check the Services Panel of your OS to verify that your Database Server process is running:
Now we have a SERVER: We need a CLIENT to talk to the SERVER: That Client is called MySQL Workbench.
Section 2: Installing MySQL Workbench on Windows 10 and 11
1. **Download MySQL Workbench:** Go to [MySQL Workbench download page](https://dev.mysql.com/downloads/workbench/) and select the version suitable for Windows. Download the installer.
2. **Start Installation:** Open the installer (.msi file) and follow the instructions. You may need to provide administrative rights.
3. **Finish Installation:** Once the installation completes, you'll find MySQL Workbench in your list of installed applications.
## **Section 3: Connect to MySQL Server through MySQL Workbench**
1. **Open MySQL Workbench:** You can find it in the Start Menu or search for it.
2. **Add Connection:** In MySQL Workbench, click on the '+' sign next to the "MySQL Connections" to add your server. Keep the "Hostname" and "Port" as is (127.0.0.1 and 3306) and enter your root password set during the MySQL Server installation.
3. **Test Connection:** After adding the details, select "Test Connection." If everything was set up correctly, you should get a successful connection message.
## **Section 4: Create and Populate a Database**
After successfully connecting to your server, here's how you could create and populate a database:
Try to make the College Enrollment Database in MySQL
1. **Create a Database**
```sql
CREATE DATABASE studentDB;
```
2. **Select the Database**
```sql
USE studentDB;
```
3. **Create a Table**
```sql
CREATE TABLE students (
student_id INT AUTO_INCREMENT,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(40) NOT NULL,
email VARCHAR(60),
PRIMARY KEY (student_id)
);
```
4. **Insert Data into the Table**
```sql
INSERT INTO students (first_name, last_name, email)
VALUES
('John', 'Doe', 'john.doe@example.com'),
('Jane', 'Doe', 'jane.doe@example.com');
```
5. **View the Data in the Table**
```sql
SELECT * FROM students;
```
Congratulations, you've installed MySQL Server and MySQL Workbench on your Windows machine and successfully run SQL commands to create and populate a database! Continue exploring SQL commands and experiment with complex database operations.
Here are step-by-step instructions to start and use MySQL Workbench:
## Starting MySQL Workbench
1. If you're using Windows, select MySQL from the Start menu and then select MySQL Workbench. Alternatively, start MySQL Workbench from the command line:
```
C:\Program Files\MySQL\MySQL Workbench 8.0\mysqlworkbench.exe
```
2. If you're using macOS, you can find MySQL Workbench in the Applications folder.
## Using MySQL Workbench
1. **Creating a new connection**
Navigate to the MySQL Workbench homepage and click on the `[+]` sign next to MySQL Connections. Here, you can set up the parameters for your new connection:
- Connection Name: This can be anything descriptive.
- Connection Method: Usually left as 'Standard (TCP/IP)'.
- Hostname: This is usually localhost (127.0.0.1)
- Username: Root (unless you have a different user set up).
- Password: It's the password you've set during installation.
- After filling in necessary details, click 'Test Connection' to ensure all parameters are correctly set up. If the connection is successful, click 'OK' to finalize the setup.
2. **Navigating to SQL Development Area**
From the homepage, under 'MySQL Connections', click on the connection you previously set up.
3. **Creating a database**
In the query tab of the SQL development area, type the following and run it (`Ctrl + Enter`)
```sql
CREATE DATABASE my_database;
```
Replace 'my_database' with the name you want for your database.
4. **Creating tables**
Run the below command to create a table:
```sql
CREATE TABLE my_database.my_table (
id INT AUTO_INCREMENT,
name VARCHAR(100),
PRIMARY KEY(id)
);
```
5. **Inserting data**
Insert data into your table using the following command:
```sql
INSERT INTO my_database.my_table(name) VALUES ('example');
```
6. **Running queries**
Here's a basic query to fetch data:
```sql
SELECT * FROM my_database.my_table;
```
With these steps, you should be able to start and use MySQL Workbench. Remember to replace `my_database` and `my_table` with your own database and table names. Also, modify the table structure and values as per your needs.
Want to print your doc? This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (