MySQL 5.7 mysql command line client using commands

  • 2021-08-12 03:55:00
  • OfStack

MySQL 5.7

MySQL command line client Use Command

1. Enter password: ******

2. ues mysql; Using Mysql

3. show databases; Display database

4. use register; Use a database named register

5. show tables; Display tables in an register database

6. describe user; Operate on the table user:


insert into user(username,password) values("xiaoyan","123456"); Insert data 
insert into user(username,password) values("ff","123456"); Insert data 
delete from user where username="xiaoyan"; Delete data 
update user set username="xiaoyan" where username="ff"; Update data 
select * from user; Query data 

7. quit; Quit

1. Displays a list of databases in the current database server:


mysql> SHOW DATABASES;

Note: The mysql library contains the system information of MYSQL. We change passwords and add new users, which is actually used for operation.

2. Display the data tables in the database:


mysql> USE  Library name; 
mysql> SHOW TABLES;

3. Display the structure of the data table:


mysql> DESCRIBE  Table name ;

4. Establish a database:


mysql> CREATE DATABASE  Library name ;

5. Establish a data table:


mysql> USE  Library name ;
mysql> CREATE TABLE  Table name  ( Field name  VARCHAR(20),  Field name  CHAR(1));

6. Delete the database:


mysql> DROP DATABASE  Library name ;

7. Delete the data table:


mysql> DROP TABLE  Table name; 

8. Empty the records in the table:


mysql> DROP TABLE  Table name; 

9. Display the records in the table:


mysql> SELECT * FROM  Table name ;

10. Insert a record into a table:


mysql> SHOW DATABASES;
0

11. Update the data in the table:


mysql> SHOW DATABASES;
1

12. Load data into the data table in text:


mysql> SHOW DATABASES;
2

13. Import. sql file command:


mysql> USE  Database name ;
mysql> SOURCE d:/mysql.sql;

14. Command line modifies root password:


mysql> SHOW DATABASES;
4

15. Display the database name of use:


mysql> SHOW DATABASES;
5

16. Display the current user:


mysql> SHOW DATABASES;
6

Related articles: