命令行下操作常用语句

 

 

Mysql服务器环境语言和本地语言不符,中文出现乱码

本地环境编码是utf8:     set names utf8;

本地环境编码是gbk:     set names gbk;

 

怎样查看mysql数据库的大小

 

用命令查看:
1、进入information_schema
数据库(存放了其他的数据库的信息)
use information_schema;

2、查询所有数据的大小:
select
concat(round(sum(data_length/1024/1024),2),'MB') as data from
tables;

3、查看指定数据库的大小:
比如查看数据库home的大小
select
concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where
table_schema='home';

4、查看指定数据库的某个表的大小
比如查看数据库home中 members
表的大小
select concat(round(sum(data_length/1024/1024),2),'MB') as data from
tables where table_schema='home' and table_name='members';

mysqldump使用方法

导出某些库
 系统命令行
 mysqldump -uusername -ppassword --databases db1 db2 > db1db2.sql

导入某个库
 系统命令行
 mysql -uusername -ppassword db1 < db1.sql;

导出数据

 

select * from doc_log where date>'2019-05-26' and op_type=3 into outfile "/tmp/doc_log.sql";

 

 

mysqldump -u -p -h -P --databases XX --tables XX --where=" date>'2019-05-26' and op_type=3" > /tmp/b.sql

 
posted on 2015-12-21 18:15  bandbandme  阅读(486)  评论(0编辑  收藏  举报