TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

MySQL

Command-Line MySQL Client

Overview

In this tutorial, we will learn about command-Line MySQL client. We can use the command-line client to connect to the MySQL Server and execute SQL queries.

We will learn how to connect to MySQL server using the command-line client.

MySQL Client

On Windows open the command prompt and type the MySQL command.

Instructions to start the MySQL client can be found here:

https://www.testingdocs.com/start-mysql-client-on-windows-11/

Get Help

We can get help by using the help command:

/> mysql –help

Command-Line Options

Some of the command-line options are as follows:

Flag/OptionParameterDescription
-hhostnamehostname or the IP address of the host machine where the MySQL Server is running or trying to connect.
-uusernameSpecify the username of the user.
-ppasswordSpecify the password of the user.
<script file.sql file to execute commands in the file.
>output fileSave the output to the file.

Examples

Let’s see some examples and usage of the mysql command.

In this example, we will connect to the local MySQL Server as a root user. We can omit the -h hostname flag if the MySQL Server and the MySQL client are running on the same machine.

/> mysql -u root -p

C:\Users\testingdocs>mysql -u root -p
Enter password: **********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.27 MySQL Community Server – GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

MySQL Command-line Client

Successful connection displays the Welcome message,Copyright information, help information and the mysql> prompt.

In the next example, we will connect to MySQL Server running on remote demo.testingdocs.com as john user and execute commands in createTables.sql SQL statement file.

/> mysql -h demo.testingdocs.com -u john < createTables.sql -p

—

MySQL Tutorials

MySQL Tutorials on this website:

https://www.testingdocs.com/mysql-tutorials-for-beginners/

For more information on MySQL Database:

https://www.mysql.com/

Related Posts

MySQL Workbench Windows 11

MySQL /

New MySQL Connection in Workbench

Start MySQL Client

MySQL /

Start MySQL Client on Windows 11

Windows 11 Services Run Prompt

MySQL /

Start MySQL Server on Windows 11

MySQL Community Downloads TDocs

MySQL /

Download & Install MySQL on Windows 11

NOW Function with whitespace

MySQL /

MySQL NOW Function

‹ Start MySQL Client on Windows 11› New MySQL Connection in Workbench

Recent Posts

  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Print Triangle Pattern Flowchart
  • RAPTOR Editions
  • Flowgorithm Conditional Breakpoint Statement
  • Flowgorithm Read Numbers from File Example
  • Search Text File Flowchart Example
  • Flowgorithm Turtle Graphics Symbols
  • Draw Circle using Flowgorithm Turtle

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version