MySQL Command Line
In this page:
mysql -u username -p
USE database_name;
SHOW TABLES;
statement;
Command Line खोलना
mysql command-line client बिना किसी GUI overhead के सीधे server से connect होता है, जो इसे quick checks, scripting, या बिना graphical tools installed किसी remote server पर SSH से काम करने के लिए सबसे तेज़ option बनाता है।
उदाहरण: Opening the Command Line
-- mysql -u root -p (run from a terminal to open the client)
SELECT 1;
Commands Execute करना
MySQL इसे execute करे उससे पहले prompt पर हर statement एक semicolon से खत्म होना ज़रूरी है — सिर्फ Enter दबाना एक नई line शुरू कर देता है, यही वजह है कि एक भूला हुआ semicolon आपको एक -> continuation prompt पर फँसा देता है।
उदाहरण: Executing Commands
SELECT 'Hello';
Databases में Navigate करना
एक database name के बाद USE चलाना session के लिए आपकी active database set करता है, इसलिए बाद के table references को हर बार database name से fully qualified होने की ज़रूरत नहीं।
उदाहरण: Navigating Databases
USE test_db;
SELECT * FROM users;
Console Output Format करना
CONCAT, UPPER, या ROUND जैसे built-in functions stored data बदले बिना display होते समय values को reshape कर सकते हैं, जो quick investigations के दौरान raw terminal output को ज़्यादा readable बनाने के लिए handy है।
उदाहरण: Formatting Console Output
SELECT CONCAT(UPPER(name), ' - ', ROUND(salary, 0)) AS summary FROM employees;
Session बंद करना
EXIT या QUIT type करना client connection को cleanly बंद कर देता है और आपके session से जुड़े server-side resources free कर देता है — connections को unnecessarily खुला छोड़ना आख़िरकार एक server की max-connection limit खत्म कर सकता है।
उदाहरण: Closing the Session
-- Type EXIT; or QUIT; at the prompt to close the client connection
- किसी statement के अंत में
;भूल जाना, ताकि prompt->में बदल जाए और कुछ न चले। - command line पर सीधे password के साथ
mysql -uroot -pलिखना, जो इसे shell history में expose कर देता है। - पहले
USEके बिना queries चलाना, ताकि आपकोNo database selectedमिले।
Chapter Quiz — Complete all 8 topics to unlock
0/8 topics done
Complete these topics first: