mysql学习需要连接服务器吗_Mysql必知必会学习笔记(三)Mysql简介+连接mysql

[root@localhost mysql_dmp]# mysql -uroot -p123456

mysql: [Warning] Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connectionid is 22Server version:5.7.25MySQL Community Server (GPL)

Copyright (c)2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type'help;' or '\h' for help. Type '\c' to clearthe current input statement.

mysql>show databases;#返回可用数据库的一个列表。+--------------------+

| Database |

+--------------------+

| information_schema |

| learn_mysql |

| mysql |

| performance_schema |

| sys |

+--------------------+

5 rows in set (0.00sec)

mysql>use learn_mysql;#USE语句并不返回任何结果。选择数据库

Reading table informationforcompletion of table and column names

You can turn off this feature to get a quicker startup with-A

Database changed

mysql>show tables;#返回当前选择的数据库内可用表的列表。

+-----------------------+

| Tables_in_learn_mysql |

+-----------------------+

| customers |

| customers2 |

| orderitems |

| orders |

| productnotes |

| products |

| vendors |

+-----------------------+

7 rows in set (0.00sec)mysql> show columns from customers;#对每个字段返回一行,行中包含字段名、数据类型、是否允许NULL、键信息、默认值以及其他信息(如字段cust_id的auto_increment)。

+--------------+-----------+------+-----+---------+----------------+

| Field        | Type      | Null | Key | Default | Extra          |

+--------------+-----------+------+-----+---------+----------------+

| cust_id      | int(11)   | NO   | PRI | NULL    | auto_increment |

| cust_name    | char(50)  | NO   |     | NULL    |                |

| cust_address | char(50)  | YES  |     | NULL    |                |

| cust_city    | char(50)  | YES  |     | NULL    |                |

| cust_state   | char(5)   | YES  |     | NULL    |                |

| cust_zip     | char(10)  | YES  |     | NULL    |                |

| cust_country | char(50)  | YES  |     | NULL    |                |

| cust_contact | char(50)  | YES  |     | NULL    |                |

| cust_email   | char(255) | YES  |     | NULL    |                |

+--------------+-----------+------+-----+---------+----------------+

9 rows in set (0.00 sec)

mysql> describe customers;#效果和show columns from customers一样

+--------------+-----------+------+-----+---------+----------------+

| Field        | Type      | Null | Key | Default | Extra          |

+--------------+-----------+------+-----+---------+----------------+

| cust_id      | int(11)   | NO   | PRI | NULL    | auto_increment |

| cust_name    | char(50)  | NO   |     | NULL    |                |

| cust_address | char(50)  | YES  |     | NULL    |                |

| cust_city    | char(50)  | YES  |     | NULL    |                |

| cust_state   | char(5)   | YES  |     | NULL    |                |

| cust_zip     | char(10)  | YES  |     | NULL    |                |

| cust_country | char(50)  | YES  |     | NULL    |                |

| cust_contact | char(50)  | YES  |     | NULL    |                |

| cust_email   | char(255) | YES  |     | NULL    |                |

+--------------+-----------+------+-----+---------+----------------+

9 rows in set (0.00 sec)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值