%mysql% Variable for MySQL Server Path

Tutorial example on how to create an environment variable '%mysql%' to represent the MySQL Server directory path name. This gives a quick way to invoke a MySQL command like '%mysql%\bin\mysql'.

Once MySQL Server is installed, we need to remember in which directory MySQL Server program and tools are located.

If you used the MySQL Installer to install MySQL, the server program and tools are located in the "C:\Program Files\MySQL\MySQL Server 8.0" directory.

If you used the MySQL Non-Install ZIP package to install MySQL, the server program and tools are probably located in the "C:\local\mysql" directory.

If you want to avoid typing the server directory path, you put it in an environment variable like "%mysql%" as shown below:

1. Go to "Control Panel > System and Security > System".

2. Click "Advanced system settings". Then click "Environment Variables".

3. Click "New" and enter:

Variable name: mysql
Variable value: "C:\Program Files\MySQL\MySQL Server 8.0"

or:
Variable name: mysql
Variable value: "C:\local\mysql"

4. Click "OK" to save the change.

Open a new command line window to invoke the "mysqladmin" tool:

herong> %mysql%\bin\mysqladmin --user=root --password=TopSecret status

Uptime: 9831  Threads: 3  Questions: 6557  Slow queries: 0  Opens: 303
   Flush tables: 3  Open tables: 192  Queries per second avg: 0.666

Good. The environment variable "%mysql%" is working.

Table of Contents

 About This Book

 Introduction of SQL

MySQL Introduction and Installation

 What Is MySQL

 Downloading and Installing MySQL

 Issues during MySQL Installation

 Starting and Stopping MySQL Server

 Un-Installing MySQL

 MySQL Command Line Client Tool

 What Is MySQL Shell

 What Is MySQL Workbench

 Using MySQL Non-Install Package

 MySQL Data Directory Initialization

 Creating MySQL Windows Service

%mysql% Variable for MySQL Server Path

 Introduction of MySQL Programs

 PHP Programs and MySQL Server

 Perl Programs and MySQL Servers

 Java Programs and MySQL Servers

 Datatypes and Data Literals

 Operations and Expressions

 Character Strings and Bit Strings

 Commonly Used Functions

 Table Column Types for Different Types of Values

 Using DDL to Create Tables and Indexes

 Using DML to Insert, Update and Delete Records

 Using SELECT to Query Database

 Window Functions for Statistical Analysis

 Use Index for Better Performance

 Transaction Management and Isolation Levels

 Locks Used in MySQL

 Defining and Calling Stored Procedures

 Variables, Loops and Cursors Used in Stored Procedures

 System, User-Defined and Stored Procedure Variables

 MySQL Server Administration

 Storage Engines in MySQL Server

 InnoDB Storage Engine - Primary and Secondary Indexes

 Performance Tuning and Optimization

 Bulk Changes on Large Tables

 MySQL Server on macOS

 Installing MySQL Server on Linux

 Connection, Performance and Second Instance on Linux

 Archived Tutorials

 References

 Full Version in PDF/EPUB