#查看当前数据库版本
select @@version ;
#查看数据库是否启用了log_bin
show variables like '%log_bin%';
#查看当前写入的日志
show master status ;
#查看日志内容
mysqlbinlog /var/lib/mysql/log-bin.000002;
#查看MySQL支持的字符集
show character set ;
#查看默认字符集
show variables like '%char%';
#查看某一库的字符集
show create database test;
#查看某一表的字符集
show create table test.t_app;
#修改字符集
alter database test character set utf8;
#查看MySQL的当前用户 SELECT USER();
#查看所有用户 SELECT user,host,password FROM mysql.user;
#查看某个用户的权限
show grants for test@'localhost';
#创建用户:
grant usage on *.* to test1@'localhost' identified by '123456' with grant option;
或者 往mysql 中的user 插入数据
insert into mysql.user(Host,User,Password) values("localhost","test2",password("123456"));
查询时设置默认值:
select coalesce(id,'0') from a;