当前位置:网站首页>mysql在cmd的登录及数据库与表的基本操作
mysql在cmd的登录及数据库与表的基本操作
2022-08-01 09:26:00 【victor_王泽华】
目录
一、登录mysql
1、Windows+R进入运行,输入cmd,进入命令窗口:

2、输入mysql -u root -p;
回车后输入密码,即可登录mysql:

二、数据库的显示、创建与删除
1.数据库的显示
登录MySQL后,输入show databases;

2.创建数据库
create database if not exists runoob;

3.删除数据库
drop database runoob;

三、表的创建、显示与删除
1.表的创建
输入use runoob;即可对数据库runoob进行操作;
输入以下命令创建runoob_tbl表:
CREATE TABLE runoob_tbl(
runoob_id INT NOT NULL AUTO_INCREMENT,
runoob_title VARCHAR(100) NOT NULL,
runoob_author VARCHAR(40) NOT NULL,
submission_date DATE,
PRIMARY KEY ( runoob_id )
)ENGINE=InnoDB DEFAULT CHARSET=utf8;

2.表的显示
在对runoob可操作的情况下,输入show tables;
即可:

输入desc runoob_tbl;
即可查看runoob_tbl的表信息

3.表的删除
在对runoob可操作的情况下,输入drop table runoob_tbl;

四、表的插入、查询数据
有的时候进行不了插入操作
Mysql>show create databese runoob;
Mysql -u root -p --default-character-set=gbk
1.表的插入
INSERT INTO runoob_tbl
(runoob_title, runoob_author, submission_date)
VALUES
("学习 mysql", "张三", NOW());
INSERT INTO runoob_tbl
(runoob_title, runoob_author, submission_date)
VALUES
("学习 php", "李四", NOW());
INSERT INTO runoob_tbl
(runoob_title, runoob_author, submission_date)
VALUES
("学习 java", "王五", NOW());

2.表的查询
输入select * from runoob_tbl;

边栏推荐
- 网络个各种协议
- CTO强烈禁止使用Calendar,那用啥?
- 正则表达式符号
- leetcode-6132: Make all elements in array equal to zero
- Idea common plugins
- MySQL query advanced - from the use of functions to table joins, do you remember?
- [Tear AHB-APB Bridge by hand]~ Why aren't the lower two bits of the AHB address bus used to represent the address?
- ASP.NET Core 6框架揭秘实例演示[30]:利用路由开发REST API
- What do the values 1, 2, and 3 in nodetype mean?
- STM32个人笔记-嵌入式C语言优化
猜你喜欢

22 Grab the Seat 1 C.Grab the Seat (Geometry + Violence)

Chapters 6 and 7 of Huawei Deep Learning Course

node 格式化时间的传统做法与高级做法(moment)

leetcode-6132:使数组中所有元素都等于零

various network protocols

net stop/start mysql80 access denied

leetcode-6134:找到离给定两个节点最近的节点

会议OA(待开会议&所有会议)

YOLOv7-Pose尝鲜,基于YOLOv7的关键点模型测评
![[Tear AHB-APB Bridge by hand]~ Why aren't the lower two bits of the AHB address bus used to represent the address?](/img/fb/c95c5857024db001638cd484c5e78f.png)
[Tear AHB-APB Bridge by hand]~ Why aren't the lower two bits of the AHB address bus used to represent the address?
随机推荐
leetcode-6133:分组的最大数量
[Interview: Concurrency 39: Multithreading: Thread Pool] ThreadPoolExecutor Class - Submit, Stop
18张图,直观理解神经网络、流形和拓扑
网络个各种协议
[Beyond programming] When the fig leaf is lifted, when people begin to accept everything
Is the real database data of TiDB stored in kv and pd?
优炫数据库支持Oracle哪几种时间及日期类型
sql server, FULL模式, dbcc shrinkfile(2,1) 不能收缩事务日志,还是原来的大小,是为什么?
HoloView——实时数据
leetcode-6134:找到离给定两个节点最近的节点
net stop/start mysql80 拒绝访问
sqlserver 对比两张表的差异
Mysql数据库的部署以及初始化步骤
How to query database configuration parameters in GBase 8c, such as datestyle
笔记。。。。
消息队列面试题(2022最新整理)
HoloView -- Tabular Datasets
Parsing MySQL Databases: "SQL Optimization" vs. "Index Optimization"
扁平数组转树结构实现方式
PerViT: 神经网络也能像人类利用外围视觉一样观察图像!