Mysql command line to create and view databases and data tables

       Database Principles This course has been a long time away. During this period, I helped students install databases many times and taught students how to use them. However, I rarely wrote projects in the last year of university, so I didn’t have them for a long time. Use a database. A few days ago, I found that mysql could not be opened, so I reinstalled it violently. Haha, it sounds a bit violent. For the specific method of installing mysql, please refer to the blog: https://blog.csdn.net/VinWqx/article/ details/104561392 , which also includes the setting of environment variables and a solution when the user password is forgotten.

1. View the current database:

mysql> show databases;

2. Create a database:

mysql> create database database_name;

3. Select and view the current database:

mysql> use database_name;
mysql> select database();

4. Create a data table:

mysql> create table mytest
    -> ( id char(3) primary key,
    ->  name char(10) 
    -> );

5. View the tables in the database:

mysql> show tables;

6. View table structure:

mysql> desc table_name;

7. View the database running status:

mysql> status

       After successfully creating a database and a table through the above operations, you can perform operations such as adding, deleting, modifying, and checking the table. If you make an error while writing sql, you can use the control+c key to exit, as shown below:

If you like it, please give it a thumbs up and encourage it.

 

 

 

 

Guess you like

Origin blog.csdn.net/VinWqx/article/details/104728328