【SQL数据库基础02】MySQL最新版安装使用教程--(安装、卸载、登录、常用命令、语法规范、图形化界面SQLyog)

01 安装教程

1.1 官网下载:

https://www.mysql.com/

img

2021官网排版,直接拉到最下面

img

img

img

1.2 六个步骤:下载安装

1.双击,32位和64位是相互兼容的

img

2.同意协议

img

3.选择安装模式,这里是自定义

img

4.安装路径,注意一定是非中文无特殊符号的路径!

img

5.安装即可

img

img

6.有两页广告,可跳过

img

安装完成!

img

1.3 配置环境

1.到这一步仅仅是环境安装好了,还没有配置。

img

要是不小心叉掉了配置页面,可以见下图

img

2.打开配置程序的实例

img

img

img

img

img

开发过程通常不选,因为总会有人攻击该端口

img

img

img

img

安装完成

img

1.4 配置my.ini

  • 可以修改端口
  • 可以修改存储目录

img

img

配置完千万记得重启一下MySQL服务

1.5 打开MySQL服务

方法一:

img

方法二:命令行方式

img

启动:net start mysql服务名
停止:net stop mysql服务名

02 卸载教程

方法一:常规软件卸载

1.主文件卸载

img

2.找到安装路径,删除残留文件

img

3.最后,在C盘中会有隐藏文件夹“ProgramData”,里面会有一些数据

img

方法二:通过软件卸载

  • 360卸载
  • 软件管家等等

img

  • 一般不需要清理注册表,除非卸载后安装还是有问题

03 MySQL服务端的登录和退出

登录 mysql –h 主机名 –u用户名 –p密码

退出 exit

img

04 SQL常见命令

show databases; 查看所有的数据库
use 库名; 打开指定 的库
show tables ; 显示库中的所有表
show tables from 库名;显示指定库中的所有表
create table 表名(
	字段名 字段类型,	
	字段名 字段类型
); 创建表

desc 表名; 查看指定表的结构
select * from 表名;显示表中的所有数据

05 MySQL的常见命令

  • 不区分大小写

  • 每句话用;或\g结尾

  • 各子句一般分行写

  • 关键字不能缩写也不能分行

  • 用缩进提高语句的可读性

\1. 进入 mysql, 在命令行中输入: mysql –uroot –p#### (其中:####表示密码)

\2. 查看 mysql 中有哪些个数据库: show databases; (2)

\3. 使用一个数据库: use 数据库名称**;** (3. atguigu)

4. 新建一个数据库**: create database** 数据库名 (1. atguigu)

\5. 查看指定的数据库中有哪些数据表: show tables; (4, 6, 9)

6. 建表: img(5)

\7. 查看表的结构:desc 表名 (7)

\8. 删除表: drop table 表名 (8)

9.查看表中的所有记录: select * from 表名;

10.向表中插入记录:insert into 表名(列名列表) values(列对应的值的列表);

img

注意:插入 varchar 或 date 型的数据要用 单引号 引起来

11.修改记录: update 表名 set 列1 = 列1的值, 列2 = 列2的值 where …

img

12.删除记录: delete from 表名 where ….

img

13.查看服务器版本

方式一:登录到mysql服务端

select version();

方式二:没有登录到mysql服务端

mysql --version

或者 mysql -v

1.查看当前所有的数据库
show databases;
2.打开指定的库
use 库名
3.查看当前库的所有表
show tables;
4.查看其它库的所有表
show tables from 库名;
5.创建表
create table 表名(

	列名 列类型,
	列名 列类型,
	。。。
);
6.查看表结构
desc 表名;
7.查看服务器的版本
方式一:登录到mysql服务端
select version();
方式二:没有登录到mysql服务端
mysql --version
或
mysql --V

06 MySQL的语法规范

1.不区分大小写,但建议关键字大写,表名、列名小写

2.每条命令最好用分号结尾

3.每条命令根据需要,可以进行缩进 或换行

4.注释

​ 单行注释:#注释文字

​ 单行注释:-- 注释文字

​ 多行注释:/* 注释文字 */

07 图形化界面客户端SQLyog

7.1 安装教程

傻瓜式安装(略)

img

7.2 界面

1.连接界面

img

img

附:SQL常用命令实操

在CMD命令行中启动MySQL,并进行常见命令的练习记录

Microsoft Windows [版本 6.1.7600]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

C:\Windows\system32>net stop mysql0815
MySQL0815 服务正在停止.
MySQL0815 服务已成功停止。


C:\Windows\system32>net start mysql0815
MySQL0815 服务正在启动 .
MySQL0815 服务已经启动成功。


C:\Windows\system32>mysql -h localhost -P 3306 -u root -p
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.15 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, 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> exit
Bye

C:\Windows\system32>mysql -h localhost -P 3306 -u root -proot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.15 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, 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> exit
Bye

C:\Windows\system32>mysql -u root -proot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.5.15 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

mysql> use test;
Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql> show tables from mysql;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| servers                   |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
24 rows in set (0.00 sec)

mysql> select database();
+------------+
| database() |
+------------+
| test       |
+------------+
1 row in set (0.00 sec)

mysql> create table stuinfo(
    -> id int,
    -> name varchar(20));
Query OK, 0 rows affected (0.01 sec)

mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| stuinfo        |
+----------------+
1 row in set (0.00 sec)

mysql> desc stuinfo;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id    | int(11)     | YES  |     | NULL    |       |
| name  | varchar(20) | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

mysql> select * from stuinfo;
Empty set (0.00 sec)

mysql> insert into stuinfo (id,name) values(1,'john');
Query OK, 1 row affected (0.00 sec)

mysql> insert into stuinfo (id,name) values(2,'rose');
Query OK, 1 row affected (0.00 sec)

mysql> select * from stuinfo;
+------+------+
| id   | name |
+------+------+
|    1 | john |
|    2 | rose |
+------+------+
2 rows in set (0.00 sec)

mysql> update stuinfo set name='lilei' where id=1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from stuinfo;
+------+-------+
| id   | name  |
+------+-------+
|    1 | lilei |
|    2 | rose  |
+------+-------+
2 rows in set (0.00 sec)

mysql> delete from stuinfo where id=1;
Query OK, 1 row affected (0.00 sec)

mysql> select * from stuinfo;
+------+------+
| id   | name |
+------+------+
|    2 | rose |
+------+------+
1 row in set (0.00 sec)

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.5.15    |
+-----------+
1 row in set (0.00 sec)

mysql> exit
Bye

C:\Windows\system32>mysql --version
mysql  Ver 14.14 Distrib 5.5.15, for Win32 (x86)

C:\Windows\system32>mysql -V
mysql  Ver 14.14 Distrib 5.5.15, for Win32 (x86)

C:\Windows\system32>mysql -uroot -p
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.5.15 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, 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> show DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

mysql> SHOW DATABASES\g
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

mysql> use test;
Database changed
mysql> select * from stuinfo;
+------+------+
| id   | name |
+------+------+
|    2 | rose |
+------+------+
1 row in set (0.00 sec)

mysql> select *
    -> from stuinfo;
+------+------+
| id   | name |
+------+------+
|    2 | rose |
+------+------+
1 row in set (0.00 sec)

mysql> SELECT
    -> *
    -> FROM
    -> stuinfo;
+------+------+
| id   | name |
+------+------+
|    2 | rose |
+------+------+
1 row in set (0.00 sec)

mysql> select * from stuinfo;
+------+------+
| id   | name |
+------+------+
|    2 | rose |
+------+------+
1 row in set (0.00 sec)

mysql> #select * from stuinfo;
mysql>

【学习资料】

【01学习笔记】
【02课程资料】
  • 6
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

是我,Zack

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值