Ubuntu operation MySQL (login, build database, build table)

Note: For all operations, there should be " ; " not less.

primary:

1. Log in to MySQL

mysql -uroot -p密码

2. Create a database (xxx_db)

mysql> create database if not exists xxx_db;

3. Switch to the xxx_db database

mysql> use xxx_db;

4. Create a table in the database

create table if not exists one_table(
  id int auto_increment, 
  a varchar(50) not null, 
  b varchar(5), 
  c varchar(10) not null, 
  d int not null, 
  e DATE, 
  primary key(id)
);

5. View table structure

mysql> desc appList;

6. Log in directly to the established database

mysql -uroot -p密码 xxx_db;

intermediate:

1. Check which databases are there

mysql> show databases;

2. Reach a certain database

mysql> use xxx_db;

3. Show the tables in the database

mysql> show tables;

4. View the data in the table

mysql> select * from xxx_table;

5. Delete the data in the table

mysql> delete from xxx_table

5. Delete table

mysql> drop table xxx_table;

 

 

 

Guess you like

Origin blog.csdn.net/weixin_38664232/article/details/105905168
Recommended