连接数据库管理系统
baozi@ubuntu:~$ mysql -u root -p
Enter password:
查看数据库管理系统中的所有数据库
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
选择数据库
就像编辑Excel要先选中文件一样,操作数据库也要先选择一个数据库
mysql> use mysql;
Database changed
查看数据库中的所有表
mysql> show tables;
+----------------------------------------------+
| Tables_in_mysql |
+----------------------------------------------+
| columns_priv |
| component |
| db |
| default_roles |
| engine_cost |
| func |
| general_log |
| global_grants |
| gtid_executed |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| innodb_index_stats |
| innodb_table_stats |
| password_history |
| plugin |
| procs_priv |
| proxies_priv |
| replication_asynchronous_connection_failover |
| role_edges |
| server_cost |
| servers |
| slave_master_info |
| slave_relay_log_info |
| slave_worker_info |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+----------------------------------------------+
34 rows in set (0.00 sec)
查看表中每一列的定义
mysql> show columns from component;
+--------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+--------------+------+-----+---------+----------------+
| component_id | int unsigned | NO | PRI | NULL | auto_increment |
| component_group_id | int unsigned | NO | | NULL | |
| component_urn | text | NO | | NULL | |
+--------------------+--------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)
退出登录
mysql> \q
Bye