mysql常用命令

mysql.server start 
启动服务器

mysql.server stop 
停止服务器

msql.server­­log


2、查询命令

select version() 
查询版本号

select current_date 
查询当前日期


3、显示命令

show databases 
显示数据库列表

show tables 显示库中的数据表

describe 表名 显示数据表的结构

select * from 表名 显示表中的记录

select what_to_select from which table [whereconditions_to_satisfy and (or) where conditions_to_satisfy] 从一个表中检索数据『满足条件』

select 字段1,字段2,… from 表名 显示特定列的值

select * from 表名 order by 字段名 排序行

select 字段1,包含字段2的运算式as 新字段 from 表名 字段值运算操作

select 字段1 is null(is not null) 空值操作

Select*from表名where字段名like(not like) “ 字符” 
注: 允许使用“_”匹配任何单个字符, 而“%” 匹配任意数目字符 模式匹配

Select * from表名where字段名regexp(not regexp)或者rlike(not rlike) “.”匹配任何单个的字符 一个字符类[…]匹配方框内任何字符。例如[a],[asd],[az] 匹配任何小写字母,[09] 匹配任何数

字。 “*”匹配零个或者多个在它前面的东西。 正则表达式区分大小写[aA] 。 如果它出现在被测试值的任何地方,模式都匹配。 定位,在模式开始处用“^”,结尾处用“$”,例如“^b” 
扩展正则表达式

Select count(*) from 表名 
Select 字段名,count(*) from 表名 group by 字段名 行计数


4、编辑命令

use database 库名 
使用的数据库

create database 库名 
创建数据库

create table 表名 
在数据库中创建表

insert into表名values (“data”,”data”) 
向表中添加记录

Load data infile “/path/filename” intotable 表名 
从文件中向表添加数据, 文件每行包括一条记录, 用定位符(tab) 把值分开。

drop database 库名 
删除数据库

drop table 表名 
删除数据库中的表

delete from表名where 
删除数据库表中的记录

Update表名set字段=”值” wherewhereconditions_to_satisfy 
更新数据库表中记录的值

原文地址:https://www.cnblogs.com/elleniou/p/2697979.html