MySQL使用小记

时间格式化:

select date_format('2008-08-08 22:23:01', '%Y%m%d%H%i%s');

去重复:

use iksdb3;
select distinct `frequency` from iksdb3.channel;

变量:

show variables like 'log';

更新时间(加一年):

update iksdb3.iksuser set expire=date_add(expire, interval +1 year) where chipsn='8b73b8499b820000';

锁定表与解锁:

use iksdb3;
flush tables with read lock;
unlock tables;

授予复制权限:

grant replication slave on *.* to 'dbrep'@'192.168.0.110';

 查看与设置最大连接数:

show variables like 'max_connections';
show global status like 'max_used_connections';
set GLOBAL max_connections=1500;
//或修改my.cnf中的max_connections参数

 正则表达式以大写开头:

select * from t_inventory_J1600352 where chipId REGEXP BINARY "^[A-Z]{1}";

 Ubuntu 14.04 LTS安装mariadb后只有root能登陆

问题: 使用sudo mysql可以登录,使用mysqladmin设置密码后,普通用户无法登录.

select user, plugin from user; 可以看到,用户的plugin为unix_socket

update user set plugin=” where user=’root’; 将plugin清空.

posted @ 2015-11-10 16:10  回首郑板桥  阅读(190)  评论(0编辑  收藏  举报