- 数据库登录:
mysql -u root -p
- 查看已有数据库:
show databases;
- 切换到某数据库:
use database_name;
- 查看某数据库下所有表:
show tables;
```
- 查看某表的描述:
```
desc table_name;
```
- 查看某表所有项:
```
select * from table_name;
```
- 清空某表:
```
delete from table_name;
```
- 将表ID计数归1:
```
alter table table_name auto_increment=1;
```
- 导出某数据库为.sql:
```
mysqldump -u root -p database_name>database_name.sql
```
- 从.sql文件恢复到数据库:
```
mysql -u root -p database_name<database_name.sql
```
网友评论