Skip to content
CODE THE PIXEL
Misc

Connecting MySQL to Windows 11 Command Prompt (CMD) / PowerShell

Asyraf Wahi Anuar 4 min read Beginner

open mysql in CLI windows 11

Key takeaways

  • Add the Laragon MySQL bin directory to the System PATH so the mysql command works from any directory.
  • Connect with mysql -u root, since Laragon sets the MySQL root user with no password by default.
  • All SQL statements in the MySQL console must end with a semicolon before pressing Enter.
  • Use SHOW DATABASES, USE, SHOW TABLES, DESCRIBE and SELECT * to inspect databases, tables and data.
  • Exit the MySQL console with EXIT; or QUIT; to return to the Windows command prompt.

Tech stack

  • MySQL

Before you start

  • MySQL

This guide provides a complete, step-by-step walkthrough for connecting Laragon’s bundled MySQL instance to the Windows 11 Command Prompt (CMD) or PowerShell. It also covers a quick-reference list of fundamental MySQL CLI commands for database administration.

Step 1: Add MySQL to System Environment Variables (PATH)

Adding MySQL to your System PATH allows you to run the mysql command from any directory in CMD or PowerShell without navigating to the installation folder every time.

  1. Press the Windows Key, search for Environment Variables, and select Edit the system environment variables.

  2. Click the Environment Variables... button at the bottom right.

  3. In the System variables section (bottom pane), select the Path variable and click Edit....

  4. Click New on the right side and paste the path to your Laragon MySQL bin directory:

    Plain text
    C:\laragon\bin\mysql\mysql-8.x.x\bin

    Note: Check your local folder (C:\laragon\bin\mysql\) to get the exact version folder name (e.g., mysql-8.0.30-winx64 or similar).

  5. Click OK on all windows to save the changes.

Step 2: Connect to MySQL via CMD / PowerShell

By default, Laragon configures the MySQL root user with no password (blank).

  1. Open Command Prompt (CMD) or PowerShell (Press Win + R, type cmd, and hit Enter).

  2. Run the following command:

Plain text
mysql -u root

Upon successful connection, your prompt will change to mysql>:

Plain text
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.30

mysql>

Step 3: Essential MySQL CLI Commands

Important: All SQL statements in the MySQL interactive console must end with a semicolon (;) before pressing Enter.

  1. View List of Databases

To see all available databases:

Plain text
SHOW DATABASES;
  1. Select / Switch Database

To work with a specific database, select it using:

Plain text
USE your_database_name;
  1. View List of Tables

Once inside a database, view all its tables with:

Plain text
SHOW TABLES;
  1. View Table Structure & Attributes (Columns, Data Types, Keys)

To inspect the columns, data types, nullability, primary keys, and extra attributes of a table:

Plain text
DESCRIBE your_table_name;

(Alternatively, you can run SHOW COLUMNS FROM your_table_name;)

  1. View Table Data (Records)

To display the actual data rows inside a table:

Plain text
SELECT * FROM your_table_name;
  1. Exit MySQL Console

To disconnect and return to the standard Windows command prompt:

Plain text
EXIT;

(or QUIT;)

Did this tutorial help?

0 readers found this helpful

Comments

No comments yet. Questions about this tutorial are welcome here: the answer helps the next reader too.

Leave a comment

Markdown works: `code`, ``` blocks, **bold**, links.

First comments are reviewed before they appear.

Misc

Git Tutorial: Uploading a Project to GitHub and Collaborating with Others

Version control is essential for developers, and Git is a powerful tool that helps manage project changes efficiently. GitHub, a popular platform built on Git, not only hosts repositories but also facilitates collaboration among developers worldwide. In this tutorial, we will explore the process of...

4 min read

Misc

Git Pull Error in cPanel

Solving cPanel Git pull error by using the composer install no dev optimized autoloader

2 min read

With your permission, this site uses Google Analytics cookies to count visits and see which tutorials are read. Nothing is set until you accept. Privacy Policy