linux mysql 查看数据库
时间: 2023-07-25 20:35:50 浏览: 54
在 Linux 中,可以使用以下命令查看 MySQL 数据库:
1. 登录 MySQL:
```
mysql -u 用户名 -p
```
2. 显示所有数据库:
```
SHOW DATABASES;
```
3. 选择要查看的数据库:
```
USE 数据库名;
```
4. 显示该数据库中的所有表:
```
SHOW TABLES;
```
5. 查看表结构:
```
DESCRIBE 表名;
```
6. 查看表中数据:
```
SELECT * FROM 表名;
```
注意:以上命令均需要在 MySQL 命令行中执行。
相关问题
linux查看mysql数据库
要在Linux上查看MySQL数据库,可以使用以下命令:
1. 登录MySQL:
```
mysql -u 用户名 -p
```
2. 显示所有数据库:
```
show databases;
```
3. 选择要使用的数据库:
```
use 数据库名;
```
4. 显示数据库中的所有表:
```
show tables;
```
5. 显示表结构:
```
describe 表名;
```
6. 显示表中的数据:
```
select * from 表名;
```
以上是一些常用的MySQL命令,可以帮助你在Linux上查看和管理MySQL数据库。
linux查看mysql数据库大小
可以通过以下步骤查看 MySQL 数据库的大小:
1. 登录 MySQL:
```
mysql -u username -p
```
其中 `username` 是你的 MySQL 用户名。
2. 选择你要查看的数据库:
```
use your_database_name;
```
其中 `your_database_name` 是你要查看的数据库名称。
3. 查看数据库大小:
```
SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB" FROM information_schema.TABLES GROUP BY table_schema ;
```
这条 SQL 语句会显示所有数据库的名称和大小。你也可以将 `table_schema` 替换为具体的数据库名称,只查看该数据库的大小。
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)