Loading Page Content...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
While graphical tools like MySQL Workbench are convenient, true database professionals and backend engineers must master the MySQL Command-Line Interface (CLI). Server deployments, Docker containers, remote cloud servers (AWS EC2, Google Cloud Compute), and CI/CD automated deployment pipelines interact with databases purely via terminal commands.
To connect to a local or remote MySQL Server from your terminal:
When prompted, type your password. Note that on Unix/Linux systems, no asterisks or characters are shown while typing passwords for security. Press Enter.
Once successfully logged in, you will be greeted with the MySQL prompt:
Inside the mysql> prompt, every SQL statement must terminate with a semicolon (;) or \G.
If you press Enter without a semicolon, MySQL expects you to continue typing on the next line. Notice how the prompt changes:
mysql>: Ready for a new command.->: Continuation of the current multiline statement.'>: Unclosed single quote waiting for closing quote.">: Unclosed double quote waiting for closing quote.>: Unclosed backtick waiting for closing backtick.If you make a typo and want to cancel the current multiline statement without executing it, type \c and press Enter:
\G)When inspecting wide tables with 20+ columns, the standard horizontal table layout wraps around the terminal and becomes unreadable. In MySQL CLI, end your statement with \G (capital G) instead of a semicolon to format results vertically!
To exit the MySQL monitor and return to your operating system shell:
mysql -u root -p indicates that a password will be provided?\G instead of a semicolon accomplish in the MySQL CLI?'> indicate in the MySQL CLI?Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| Installing MySQL Server | Setting Up MySQL Workbench |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.