在linux中查看mysql数据库中表

1
2
3
4
5
6
7
8
9
10
11
mysql -uroot -p //进入数据库

show databases; //查看musql中数据库列表

use dataname; //选择数据库名

show tables; // 查看数据库中的所有表

describe tablename; //查看表结构

最后对表进行sql语句操作

过程:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
| typecho |
+--------------------+
5 rows in set (0.00 sec)

MariaDB [(none)]> use typecho;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [typecho]> show tables;
+-----------------------+
| Tables_in_typecho |
+-----------------------+
| typecho_comments |
| typecho_contents |
| typecho_fields |
| typecho_metas |
| typecho_options |
| typecho_relationships |
| typecho_users |
+-----------------------+
7 rows in set (0.00 sec)

MariaDB [typecho]> describe typecho_users;
+------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+------------------+------+-----+---------+----------------+
| uid | int(10) unsigned | NO | PRI | NULL | auto_increment |
| name | varchar(32) | YES | UNI | NULL | |
| password | varchar(64) | YES | | NULL | |
| mail | varchar(200) | YES | UNI | NULL | |
| url | varchar(200) | YES | | NULL | |
| screenName | varchar(32) | YES | | NULL | |
| created | int(10) unsigned | YES | | 0 | |
| activated | int(10) unsigned | YES | | 0 | |
| logged | int(10) unsigned | YES | | 0 | |
| group | varchar(16) | YES | | visitor | |
| authCode | varchar(64) | YES | | NULL | |
+------------+------------------+------+-----+---------+----------------+
11 rows in set (0.00 sec)