Embedded within your MySQL installation is a handy utility known as MySQL, facilitating direct SQL query submission to the MySQL server with subsequent output in text format. This tool serves as a rapid and convenient means to validate your MySQL setup.
Procedures

Locate the MySQL Utility (Typically nested within a subdirectory labeled bin in the MySQL installation directory)
- For instance, on Windows systems: C:\mysql\bin\mysql.exe
- Alternatively, on Linux/Unix platforms: /usr/local/mysql/bin/mysql

Commence MySQL - Input the following command within the command line interface: mysql -h hostname -u username -p,
- Specifying
- hostname as the server machine hosting MySQL
- username corresponding to the MySQL account to be utilized
- -p prompts MySQL to request the account password.

Input your password when prompted.


Running Without the Command Line Interface.

Locate the MySQL Utility (Typically nestled within a subdirectory labeled bin in the MySQL installation directory)
- For example, on Windows systems: C:\mysql\bin\mysql.exe
- Alternatively, on Linux/Unix platforms: /usr/local/mysql/bin/mysql

Initiate MySQL. Within the command line interface, enter: mysql -h hostname -u username -p db_name -e 'query'
- where
- host represents the machine hosting the MySQL server
- username pertains to the MySQL account being utilized
- -p prompts MySQL to request the account password.
- db_name refers to the name of the database where the query will execute, and,
- query signifies the SQL query to be executed.


Pointers
-
Ensure to append a semicolon at the conclusion of your query when using the console to signify query completion.
-
You can specify the password directly after -p in the command line, for example, mysql -u username -h host -ppassword. Note the absence of space between -p and the password.
-
If executing from the command line without utilizing the shell, employ the -B flag (e.g., mysql -u username' -h host -p db_name -Be 'query') to obtain output in batch mode instead of MySQL's default tabular mode, facilitating further processing.
Precautions
- Ensure thorough review of queries prior to execution to prevent accidental deletion of entire databases!