![](https://csdnimg.cn/release/download_crawler_static/88815476/bg7.jpg)
/*权限控制---------------*/
create user 'itcast'@'localhost' identified by '123456';
/*查询权限*/
show grants for 'itcast'@'localhost';
/*授予权限*/
grant all on test.* to 'itcast'@'localhost';
/*撤销权限*/
revoke all on test.* from 'itcast'@'localhost';
多个权限之间用逗号隔开
函数------------------------------------------------------------------
字符串函数
select
concat
('hello','mysql');/*字符串拼接*/
select
lower
('HELlo');/*转小写*/
select
upper
('hello');/*转大写*/
select
lpad
('hello',10,'-');
select
rpad
('hello','10','=');/*字符串左右填充至几个,用-填充*/
select
trim
(' hello mysql ');/*去除两端空格*/
select
substring
('hello mysql',1,7);/*从第 1 个字开始截取 7 个*/
数值函数
/*数值函数*/
select
ceil
(1.5);
select
floor
(1.5);/*向上向下取整*/
select
mod
(3,5);
select
mod
(6,4);/*求模*/
select
rand
();/*0-1 的随机数*/
select
rand
()*5;/*0-5 的随机数*/
select
round
(2.336,2);/*对小数进行四舍五入 保留 2 位小数*/
/*产生 6 位随机验证码*/
select
lpad
(
round
(
rand
()*1000000,0),6,'0') ;
日期函数
/*日期函数*/
select
curdate
();
select
curtime
();
select
now
();/*当前日期时间*/
select
year
(
now
());
select
month
(
now
());
select
day
(
now
());
select
hour
(
now
()),
minute
(
now
()),
second
(
now
());
use test;
select
date_add
(
now
(),interval 70 day );