DBA
#### 一、构建MySQL数据库
```shell
# 环境配置
mysql50:
echo -> 192.168.88.50
mysql51:
echo -> 192.168.88.50
# 安装服务
yum -y install mysql-server mysql
# 启动服务
# 查看进程
```
#### 二、密码管理
```shell
# 修改密码
mysqladmin -uroot -p[旧密码] password "新密码"
# 破解密码 /etc/my.cnf.d/mysql-server.cnf
[mysqld]
skip_grant_tables //手动添加登陆时跳过验证密码,重启生效
# 在mysql中设置密码
alter user root@'localhost' identified by 'a';
```
#### 三、条件查询
```shell
# 比较匹配
# 范围匹配
in (值列表) //在…里
not in (值列表) //不在…里
between 数字1 and 数字2 //在…之间
# 模糊匹配
where 字段名 like "表达式";
_ 表示 1个字符
% 表示零个或多个字符
# 正则匹配
where字段名 regexp '正则表达式';
^ 匹配行首
$ 匹配行尾
[] 匹配范围内任意一个
* 前边的表达式出现零次或多次
| 或者
. 任意一个字符
# 逻辑比较
与 and 、或 or 、非 not
()提高优先级
#
空 is null 表头下没有数据
非空 is not null 表头下有数据
# 别名/去重/合并
定义别名使用 as 或 空格:列名 as 别名,列名 别名
去重显示 distinct 字段名列表:distinct 列名
拼接 concat():concat(列名,列名)
```