mysql 操作记录
2018-03-28 本文已影响5人
李孝伟
1. mysql设置行号
mysql 中没有row_number()一说,所以需要自己实现行号;
可以通过自定义变量的方式实现:
select *,
@rownum := @rownum +1 as num
from tablename , (select @rownum:=0) t ;
顺便说下group by 取其中一条的,可以结合一些函数一起使用,比如max()等。
2. 创建数据库并指定编码
```
create database xxx character set utf8 collate utf8_general_ci;
```
3. 创建用户
```
set global validate_password_policy=0; //去掉复杂密码限制
create user 'xaaa@%' identified by 'xxxxxx';
grant all on bxxx.* to 'xaaa@%';
flush privileges;
```