ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

mysql-8.0.18基础操作快速入门

2020-01-29 22:39:14  阅读:418  来源: 互联网

标签:8.0 set mydatabase 18 rows sec mysql


mysql-8.0基础操作快速入门

1 mysql下载与安装使用

    前往mysql官网下载对应版本,我选择的版本是mysql-8.0.18-winx64
    将下载到的压缩包解压,然后在cmd窗口进入内部bin目录,使用如下命令启动mysql后台服务

D:\mysql-8.0.18-winx64\bin>mysqld

    新开cmd窗口,进入内部bin目录,使用如下命令

D:\mysql-8.0.18-winx64\bin>mysql -u root -p
Enter password: **********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.18 MySQL 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 clear the current input statement.

mysql>

成功进入mysql交互模式。

2 mysql基础命令

mysql> show databases;//显示所有的数据库
+--------------------+
| Database           |
+--------------------+
| bj18               |
| db111              |
| information_schema |
| mysql              |
| mytest             |
| performance_schema |
| sys                |
| webby              |
+--------------------+
8 rows in set (0.03 sec)

mysql> create database mydatabase;//创建一个数据库,命名为mydatabase
Query OK, 1 row affected (0.02 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| bj18               |
| db111              |
| information_schema |
| mydatabase         |
| mysql              |
| mytest             |
| performance_schema |
| sys                |
| webby              |
+--------------------+
9 rows in set (0.00 sec)

mysql> drop database mydatabase;//删除指定数据库
Query OK, 0 rows affected (0.02 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| bj18               |
| db111              |
| information_schema |
| mysql              |
| mytest             |
| performance_schema |
| sys                |
| webby              |
+--------------------+
8 rows in set (0.00 sec)

mysql> use mydatabase;//打开mydatabase数据库
					//mydatabase数据库重新创建
Database changed
//创建数据表,并指定几个域
mysql> create table student(
    -> id int(4) not null primary key auto_increment,
    -> name char(20) not null,
    -> sex int(4) not null default '0',
    -> degree double(16,2));
Query OK, 0 rows affected, 3 warnings (0.06 sec)

mysql> show tables;//查看mydatabase数据库中的所有表
+----------------------+
| Tables_in_mydatabase |
+----------------------+
| student              |
+----------------------+
1 row in set (0.01 sec)

mysql> desc student;//查看指定表的结构
+--------+--------------+------+-----+---------+----------------+
| Field  | Type         | Null | Key | Default | Extra          |
+--------+--------------+------+-----+---------+----------------+
| id     | int(4)       | NO   | PRI | NULL    | auto_increment |
| name   | char(20)     | NO   |     | NULL    |                |
| sex    | int(4)       | NO   |     | 0       |                |
| degree | double(16,2) | YES  |     | NULL    |                |
+--------+--------------+------+-----+---------+----------------+
4 rows in set (0.01 sec)

//在表中插入记录
mysql> insert into student values(1,'joan',0,89.2);
Query OK, 1 row affected (0.01 sec)

//查询表中的记录
mysql> select id,name,sex,degree from student;
+----+------+-----+--------+
| id | name | sex | degree |
+----+------+-----+--------+
|  1 | joan |   0 |  89.20 |
+----+------+-----+--------+
1 row in set (0.00 sec)

//删除指定表
mysql> drop table student;
Query OK, 0 rows affected (0.02 sec)

mysql> show tables;
Empty set (0.00 sec)

mysql>

这只是最基本的命令,比如select还有很多种用法,并没有一一列举出来emmmmm

一月换一次名字的秃头少年 发布了2 篇原创文章 · 获赞 0 · 访问量 221 私信 关注

标签:8.0,set,mydatabase,18,rows,sec,mysql
来源: https://blog.csdn.net/qq_43555886/article/details/104110540

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有