(centos)mysql的安装及基本操作
来源:互联网 发布:mac唇部打底好用么 编辑:程序博客网 时间:2024/05/18 22:44
mysql基本操作:
登陆
- 用mysql -uroot -pmolifei dbname_xxx可以直接登录到某个数据库下,省略了user dbname_xxx
write
- 创建一个数据库 create database <数据库名>;
- 增加一个字段alter table table_name add field_name varchar(255) null/ int(4) 0
- 插入一条数据 insert into table_name values('abc','ddd',31,'abc');
- 导入一个表格 source table_name;
select
- 查询当前数据库:select database();
- 查询table中的具体内容:select * from table_name;
- 查询某个table中是否存在某字段:select * from table_name where field='value';
- 查询某个table拢共多少条数据:select count(0) from table_name;括号里面可以是0、1、*
- 查询数据大小 select concat(round(sum(data_length/1024/1024),2),'MB') as data from information_schema.TABLES where TABLE_SCHEMA='resultdb';
- 查看建表语句 show create table xxx;
- 查看表结构 desc xxx;
- 当使用where时,可以采用and和or来做条件合并
- select count(*) from baihe_people where news_type like '%经济%';这个是查看news_type字段里面带有‘经济’二字的record
mysqldump
- 将数据库中的某个table导出sql文件msyqldump -uroot -pmolifei webdigging_resultdb ganji_people -w "crawlDate=`date +"%Y-%m-%d" -d "-1 days"`" > xxxx.sql
- 无论mysqldump的-w和select的where,当针对事件查询时,都可以用 ><=等来比较时间字符串
将sql文件导入数据库
- mysql -h183.131.17.236 -uweibo_crawler -p123456 weibo_crawler < /yangfg/sql_files/sina_weibo.sql,将sql文件导入到183.131.17.236中的weibo_crawler数据库中
drop
- 删除一个字段alter table table_name drop field_name;
- 删除一个table drop table table_name;
delete
- 删除一条record:delete from table_name where news_text='aa'
开启log
- 查看是否启用日志:
show variables like 'log_%'; - 查看当前的日志:
show master status;
0 0
- (centos)mysql的安装及基本操作
- Centos mysql 安装及基本操作
- mysql的安装及基本操作
- centos mysql 基本操作
- CentOS下的MySQL基本操作
- redhat mysql 安装配置及基本操作
- ubuntu下mysql安装及基本操作
- CentOS安装及操作
- CentOS安装mysql后的常用操作
- CentOs中nginx的安装及操作
- mysql的基本操作及语法规范
- MySQL 安装 (基本操作)
- Mysql安装之后的基本操作
- mysql的基本安装与操作
- MySQL的安装配置和基本操作
- MySQL的基本操作及SQL语句的基本命令
- MySQL的安装及基本使用
- linux下安装mysql详细步骤及基本操作
- Android中保存数据的四种方法
- github学习
- SQL总结 基本查询
- Python简单读写Excel (xlwt, xlrd, xlutils)
- 最疯狂的闹钟
- (centos)mysql的安装及基本操作
- Android Mediaplayer设置静音和恢复声音
- jquery的extend和fn.extend
- C++派生类的构造函数
- 直方图均衡化—图像增强
- php批量更新或插入数据
- phpunit jenkins error
- javascript: Jquery each loop with json array or object
- Javascript 创建对象方法的总结