MySQL之旅(2) 创建数据库 数据表 插入数据 MySQL可视化工具Navicat for MySQL
导言:若木有安装破解版Navicat for MySQL软甲,传送门已备好---> 传送门:安装破解版Navicat
第一步:可视化工具Navicat for MySQL连接MySQL
1·启动MySQL
npm指令--切换目录:
cd C:\web\mysql-8.0.11\bin
npm指令--初始化数据库:
mysqld --initialize --console
执行完成后,会输出 root 用户的初始默认密码:
... 2018-04-20T02:35:05.464644Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: APWCY5ws&hjQ ...
npm指令--安装 :
mysqld install
npm指令--启动:
net start mysql
2· 连接Navicat for MySQL
第二步:连接成功 创建数据库 右击Navicat左侧打开 命令列界面
tips:因为我自己MySQL前一秒写数据了 并不影响 ;
1· 创建数据库指令:
CREATE DATABASE 数据库名;
2· 使用数据库(切记 每次完整的命令结尾用 ';'):
use 数据库名;
3·数据库创建表单(表格):
mysql> create table Fruits ( -> id int(11), -> name VARCHAR(255), -> price DECIMAL(10,2), -> discount DECIMAL(10,2), -> manufacturer VARCHAR(255), -> shop VARCHAR(255), -> shopname VARCHAR(255), -> incorporation DATE, -> operationstatus tinyint(1), -> shopbox VARCHAR(255), -> address VARCHAR(255), -> onlinephone int(11) -> );
tips: 每行指令前缀 -> 是Navicat自带分行 别搞错了, Query OK, 0 rows affected 表示创建成功!
4·显示你所创建的表单 table :
show full columns from fruits;
:显示结果
+-----------------+---------------+--------------------+------+-----+---------+-------+---------------------------------+---------+ | Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment | +-----------------+---------------+--------------------+------+-----+---------+-------+---------------------------------+---------+ | id | int | NULL | YES | | NULL | | select,insert,update,references | | | name | varchar(255) | utf8mb4_0900_ai_ci | YES | | NULL | | select,insert,update,references | | | price | decimal(10,2) | NULL | YES | | NULL | | select,insert,update,references | | | discount | decimal(10,2) | NULL | YES | | NULL | | select,insert,update,references | | | manufacturer | varchar(255) | utf8mb4_0900_ai_ci | YES | | NULL | | select,insert,update,references | | | shop | varchar(255) | utf8mb4_0900_ai_ci | YES | | NULL | | select,insert,update,references | | | shopname | varchar(255) | utf8mb4_0900_ai_ci | YES | | NULL | | select,insert,update,references | | | incorporation | date | NULL | YES | | NULL | | select,insert,update,references | | | operationstatus | tinyint(1) | NULL | YES | | NULL | | select,insert,update,references | | | shopbox | varchar(255) | utf8mb4_0900_ai_ci | YES | | NULL | | select,insert,update,references | | | address | varchar(255) | utf8mb4_0900_ai_ci | YES | | NULL | | select,insert,update,references | | | onlinephone | int | NULL | YES | | NULL | | select,insert,update,references | | +-----------------+---------------+--------------------+------+-----+---------+-------+---------------------------------+---------+ 12 rows in set
5·给表单出入数据 可插入多条数据:
insert into tablename (...所要插入的参数) values (...所要插入的值)
forexample:
insert into fruits (id,name,price,discount,manufacturer,shop,shopname,incorporation,operationstatus,shopbox,address,onlinephone)
-> values ('15','iphone 8','1000.99','990.88','浙江义乌','义乌数码科技市场','iPhone体验店','2010-10-01','1','小丫丫','陕西西安雁塔','082088820'), ('16','iphone 8Plus','1070.99','919.88','浙江义乌','义乌数码科技市场','iPhone店','2010-10-01','1','小丫丫','陕西西安雁塔','082088820'),('17','ipone SE','1000.99','990.88','浙江义乌','义乌数码科技市场','iPhone店','2010-10-01','1','小丫丫','陕西西安雁塔','082088820'), ('18','iphone SE2','1070.99','919.88','浙江义乌','义乌数码科技市场','iPhone店','2010-10-01','1','小丫丫','陕西西安雁塔','082088820'),('19','iphone Max','1000.99','990.88','浙江义乌','义乌数码科技市场','iPhone店','2010-10-01','1','小丫丫','陕西西安雁塔','082088820'), ('20','vivo','1070.99','919.88','浙江义乌','义乌数码科技市场','iPhone店','2010-10-01','1','小丫丫','陕西西安雁塔','082088820'),('21','HUAWEI','1000.99','990.88','浙江义乌','义乌数码科技市场','华为体验店','2010-10-01','1','小丫丫','陕西西安雁塔','082088820'), ('22','vivo','1070.99','919.88','浙江义乌','义乌数码科技市场','vivo体验店','2010-10-01','1','小丫丫','陕西西安雁塔','082088820'),('23','HUAWEI','1000.99','990.88','浙江义乌','义乌数码科技市场','华为体验店','2010-10-01','1','小丫丫','陕西西安雁塔','082088820'), ('24','vivo','1070.99','919.88','浙江义乌','义乌数码科技市场','vivo体验店','2010-10-01','1','小丫丫','陕西西安雁塔','082088820');
tips: 显示
Query OK, 10 rows affected
Records: 10 Duplicates: 0 Warnings: 0
表示数据成功;
end...
我们不是一群默默无闻的码农,而是推进世界进步的开荒者