MySql的安装与使用

图解MySQL程序结构
一、MySql数据库产品的介绍
MySQL产品的特点
MySQL数据库隶属于MySQL AB公司,总部位于瑞典,后被oracle收购。
优点:
成本低:开放源代码,一般可以免费试用
性能高:执行很快
简单:很容易安装和使用
二、MySql数据库的安装
DBMS分为两类:
基于共享文件系统的DBMS (Access )基于客户机——服务器的DBMS
(MySQL、Oracle、SqlServer)
MySQL的版本
社区版(免费)
企业版(收费)
Windows平台下下载:http://dev.mysql.com/downloads/mysql
目前可以下载的版本:
5.5
5.6
5.7
8.0 测试版
启动和停止MySQL服务
方式一:通过计算机管理方式
右击计算机—管理—服务—启动或停止MySQL服务
方式二:通过命令行方式
启动:net start mysql服务名
停止:net stop mysql服务名
MySQL服务端的登录和退出
登录:mysql –h 主机名 –u用户名 –p密码
退出:exit
三、MySql数据库的使用
MySQL语法规范
不区分大小写每句话用;或\g结尾各子句一般分行写关键字不能缩写也不能分行用缩进提高语句的可读性
- 进入 mysql, 在命令行中输入: mysql –uroot –p#### (其中:####表示密码)
- 查看 mysql 中有哪些个数据库: show databases; (2)
- 使用一个数据库: use 数据库名称; (3. atguigu)
- 新建一个数据库: create database 数据库名 (1. atguigu)
- 查看指定的数据库中有哪些数据表: show tables; (4, 6, 9)

6. 建表: (5)
7.查看表的结构:desc 表名 (7)
8.删除表: drop table 表名 (8)

LAMP: LINUX APACHE MYSQL PHP/Perl/Python
1.查看表中的所有记录: select * from 表名;
2.向表中插入记录:insert into 表名(列名列表) values(列对应的值的列表);

3.注意:插入 varchar 或 date 型的数据要用 单引号 引起来
4.修改记录: update 表名 set 列1 = 列1的值, 列2 = 列2的值 where …

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

查询所有列: select * from 表名;
查询特定的列: select 列名1,列名2, … from 表名

对查询的数据进行过滤:使用 where 子句

运算符:



% 匹配任意多字符;
_只匹配一个字符

查询 name 中有 o 的人的名字

查询 name 中 第 3 个字母是 r 的人的名字

查询 email 为 空 的所有人的信息

查询 email 不为 空 的所有人的信息

查询所有客户信息, 且按 salary 升序排列

查询所有客户信息, 且按 salary 降序排列
四、图形化界面客户端的使用
