Skip to content

MySQL is a popular open-source relational database management system, and you can interact with it using the MySQL command-line client. Here are some commonly used MySQL terminal commands.

Notifications You must be signed in to change notification settings

lexara-prime-ai/MYSQL_CLIENT_COMMANDS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

MySQL CLI Client:

  1. Log In to MySQL: To log in to MySQL, open your terminal and run the following command. Replace <username> with your MySQL username, and you will be prompted for your password.
C:> mysql -u <username> -p
  1. Switch to a Database: After logging in, you can switch to a specific database using the USE command.
mysql> USE <database_name>;
  1. Show Databases: To list all available databases, you can use the following command:
mysql> SHOW DATABASES;
  1. Create a Database: To create a new database, use the CREATE DATABASE command:
mysql> CREATE DATABASE <database_name>;
  1. Create a Table: To create a new table within a database, use the CREATE TABLE command:
mysql> CREATE TABLE <table_name> (
	        column1 datatype,
	        column2 datatype,
	        ...
	    );
  1. Insert Data into a Table: You can insert data into a table using the INSERT INTO command:
mysql> INSERT INTO <table_name> (column1, column2, ...)
       VALUES (value1, value2, ...);
  1. Select Data from a Table: To retrieve data from a table, use the SELECT statement:
 mysql> SELECT * FROM <table_name>;
  1. Update Data in a Table: To update existing data in a table, use the UPDATE statement:
mysql> UPDATE <table_name>
       SET column1 = value1, column2 = value2, ...
       WHERE condition;
  1. Delete Data from a Table: To delete data from a table, use the DELETE statement:
mysql> DELETE FROM <table_name> WHERE condition;
  1. Show Table Structure: To view the structure of a table, you can use the DESCRIBE or SHOW COLUMNS command:
mysql> DESCRIBE <table_name>;

mysql> SHOW COLUMNS FROM <table_name>;
  1. Show Tables: you can use the SHOW TABLES command to list all the tables in the currently selected database, USE :
mysql>  SHOW TABLES;
  1. Exit MySQL: To exit the MySQL command-line client, you can type:
mysql>  EXIT;

About

MySQL is a popular open-source relational database management system, and you can interact with it using the MySQL command-line client. Here are some commonly used MySQL terminal commands.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published