mysql常用查询语句
一、查询指定schema下表的个数
select count(TABLE_NAME) from information_schema.tables where table_schema="dbname"
二、查询指定schema下每个表中的记录数
select table_name,table_rows from information_schema.tables where table_schema='XXX' order by table_rows desc
三、登录MySQL
mysql -u root -p show dbs show databases select * from `user` where `User`='root' or `User`='admin' 授权phplamp用户拥有phplamp数据库的所有权限 grant all privileges on phplampDB.* to phplamp@localhost identified by '1234'
参见:http://blog.csdn.net/call_me_lzm/article/details/52244162
四、重启服务
/etc/init.d/mysql.server status /etc/init.d/mysql.server start /etc/init.d/mysql.server stop /etc/init.d/mysql.server restart /etc/my.cnf
五、表中数据复制
insert into 表名(classid,title,address,zipCode) select classid,title,address,zipCode from ler_items
六、表备份
create table xx.t_configuration_170514 as select * from xxx.t_configuration
七、获取10分钟之前删除的数据
select * from T_MOBILE_CARD as of timestamp (systimestamp - interval '10' minute)
八、批量更新
update xxx sm set sm.list_url=replace(sm.list_url,'http://xxx','http://yyy') where sm.list_url like 'http://xxx/%';
九、查看schemata信息
mysql> select * from information_schema.SCHEMATA;
十、数据导出/导入
exp xxx/yyyy@DG_PRO BUFFER=64000 file=D:\data\middle\xxx.dmp TABLES=(t_acl_user,t_acl_role,t_acl_content)
imp xxx/yyyy@DG_PRO BUFFER=64000 file=D:\data\middle\xxx.dmp TABLES=(t_acl_user,t_acl_role,t_acl_content)