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)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值