Author Archives: Jagjit

Connect and disconnect with MySQL through command line

Connect and disconnect session with MySQL database

Go to the path where mysql is install or set path in environment variable.

cd C:\Program Files\MySQL\MySQL Server 8.0\bin

Connect with MySQL through Command Line

mysql -h host -u user -p
Enter password: ********

Example:
C:\Program Files\MySQL\MySQL Server 8.0\bin>mysql -h localhost -u root -p
Enter password: *********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 27
Server version: 8.0.24 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>


--- Connected with the Same Machine where MySQL services running
mysql -u user -p
Enter password: ********

Disconnect from the MySQL Session

quit

Example:
mysql> quit
Bye

C:\Program Files\MySQL\MySQL Server 8.0\bin>