LearninBits

Adding MySQL to Your Windows Environment Variables

Setting up MySQL on your computer is a great achievement, but to make it even more efficient to access and use the MySQL tools directly from the command prompt, you should add it to your Windows environment variables. However, if you are yet to install MySQL on your computer then follow this simple guide to install it: Installing MySQL on Windows: A Step-by-Step Guide

This guide walks you through the process.

If you have MYSQL installed on Windows but you are still getting this error “mysql is not recognized as an internal or external command, operable program or batch file” then it means that MySQL is yet to be added to your Windows environment variables.

Why Add MySQL to Environment Variables?

By adding MySQL to your environment variables, you can run MySQL commands without navigating to its bin directory every time. It’s a time-saver and a convenience you’ll appreciate, especially if you work with MySQL frequently.

Let’s Get Started!

Step 1: Locate MySQL’s `bin` Directory

– Navigate to the directory where MySQL is installed. Typically, it’s in `C:\Program Files\MySQL\MySQL Server X.Y\bin`, where `X.Y` is your MySQL version number. In the demonstration below `X.Y` refers to 8.0

– Copy the path to this directory. You’ll need it in the next steps.

(C:\Program Files\MySQL\MySQL Server 8.0\bin)

Step 2: Accessing the System Environment Variables

1. Right-click on the Windows Start button and select ‘System’.

2. Click on ‘Advanced system settings’ on the right side.

3. In the pop-up window, under the ‘Advanced’ tab, click on the ‘Environment Variables…’ button.

Step 3: Modify the ‘Path’ Variable

1. Under ‘System Variables’, find and select the ‘Path’ variable, then click on the ‘Edit…’ button.

2. In the edit window, click on the ‘New’ button and then paste the path you copied in Step 1.

3. Confirm by clicking the ‘OK’ button on each window to save your changes.

Step 4: Testing Your Setup

– Open a new command prompt (`cmd`).

– Simply type `mysql -V` and press Enter. If everything’s set up correctly, it should display the MySQL client version, proving that you can now access MySQL directly from any command prompt window.

Wrapping Up

You’ve successfully added MySQL to your environment variables. This simple tweak will streamline your workflow, making MySQL commands more accessible. 

Remember, every time you install a new version of MySQL or move its installation directory, you’ll need to update the path in the environment variables.

If you found this guide helpful, check out our other tutorials and tips on our blog. Don’t forget to follow us on Twitter @learninbits for more tech insights and updates!

1 Comment

  • Installing MySQL on Windows: A Step-by-Step Guide - LearninBits August 11, 2023 at 3:28 pm

    […] You can however follow this guide to add MySQL to your environment variables: Adding MySQL to Your Windows Environment Variables […]

Leave a Reply

Layer 1