Linux常用指令---mysql 语句
2016-02-17 15:44
585 查看
耍了整整10天的春节假,节后第一天上班,事情不多,提不起多大的精神。
今天回顾Linux常用指令的关于mysql语句。
flush privileges; # 刷新
show databases; # 显示所有数据库
use dbname; # 打开数据
show tables; # 显示选中数据库中所有的表
desc tables; # 查看表结构
drop database name; # 删除数据库
drop table name; # 删除表
create database name; # 创建数据库
select 列名称 from 表名称; # 查询
show grants for repl; # 查看用户权
show processlist; # 查看mysql进程
select user(); # 查看所有用户
show slave status\G; # 查看主从状态
show variables; # 查看所有参数变量
show table status # 查看表的引擎状态
drop table if exists user # 表存在就删除
create table if not exists user # 表不存在就创建
select host,user,password from user; # 查询用户权限 先use mysql
create table ka(ka_id varchar(6),qianshu int); # 创建表
SHOW VARIABLES LIKE ‘character_set_%’; # 查看系统的字符集和排序方式的设定
show variables like ‘%timeout%’; # 查看超时(wait_timeout)
delete from user where user=”; # 删除空用户
delete from user where user=’sss’ and host=’localhost’ ; # 删除用户
ALTER TABLE mytable ENGINE = MyISAM ; # 改变现有的表使用的存储引擎
SHOW TABLE STATUS from 库名 where Name=’表名’; # 查询表引擎
CREATE TABLE innodb (id int, title char(20)) ENGINE = INNODB # 创建表指定存储引擎的类型(MyISAM或INNODB)
grant replication slave on . to ‘用户’@’%’ identified by ‘密码’; # 创建主从复制用户
ALTER TABLE player ADD INDEX weekcredit_faction_index (weekcredit, faction); # 添加索引
alter table name add column accountid(列名) int(11) NOT NULL(字段不为空); # 插入字段
update host set monitor_state=’Y’,hostname=’xuesong’ where ip=’192.168.1.1’; # 更新数据
自增表
create table oldBoy (id INTEGER PRIMARY KEY AUTO_INCREMENT, name CHAR(30) NOT NULL, age integer , sex CHAR(15) ); # 创建自增表
insert into oldBoy(name,age,sex) values(%s,%s,%s) # 自增插入数据
今天回顾Linux常用指令的关于mysql语句。
flush privileges; # 刷新
show databases; # 显示所有数据库
use dbname; # 打开数据
show tables; # 显示选中数据库中所有的表
desc tables; # 查看表结构
drop database name; # 删除数据库
drop table name; # 删除表
create database name; # 创建数据库
select 列名称 from 表名称; # 查询
show grants for repl; # 查看用户权
show processlist; # 查看mysql进程
select user(); # 查看所有用户
show slave status\G; # 查看主从状态
show variables; # 查看所有参数变量
show table status # 查看表的引擎状态
drop table if exists user # 表存在就删除
create table if not exists user # 表不存在就创建
select host,user,password from user; # 查询用户权限 先use mysql
create table ka(ka_id varchar(6),qianshu int); # 创建表
SHOW VARIABLES LIKE ‘character_set_%’; # 查看系统的字符集和排序方式的设定
show variables like ‘%timeout%’; # 查看超时(wait_timeout)
delete from user where user=”; # 删除空用户
delete from user where user=’sss’ and host=’localhost’ ; # 删除用户
ALTER TABLE mytable ENGINE = MyISAM ; # 改变现有的表使用的存储引擎
SHOW TABLE STATUS from 库名 where Name=’表名’; # 查询表引擎
CREATE TABLE innodb (id int, title char(20)) ENGINE = INNODB # 创建表指定存储引擎的类型(MyISAM或INNODB)
grant replication slave on . to ‘用户’@’%’ identified by ‘密码’; # 创建主从复制用户
ALTER TABLE player ADD INDEX weekcredit_faction_index (weekcredit, faction); # 添加索引
alter table name add column accountid(列名) int(11) NOT NULL(字段不为空); # 插入字段
update host set monitor_state=’Y’,hostname=’xuesong’ where ip=’192.168.1.1’; # 更新数据
自增表
create table oldBoy (id INTEGER PRIMARY KEY AUTO_INCREMENT, name CHAR(30) NOT NULL, age integer , sex CHAR(15) ); # 创建自增表
insert into oldBoy(name,age,sex) values(%s,%s,%s) # 自增插入数据
相关文章推荐
- Linux信号机制
- linux命令:mv命令
- Linux 的cp命令
- CentOS7創建本地yum/配置IP/OL6.6進入系統界面
- linux下使用yum安装mysql5.1详解
- linux解决dns解析问题
- 基于linux的ekho(余音)安装与开发
- linux 查找目录下文本内容字符串
- linux配置java环境变量(详细)
- linux操作系统下的码农常用工具
- java在linux下安装
- Linux系统扫描技术及安全防范
- 打开linux主机的端口快速释放
- 利用eclipse自带插件远程访问linux
- CentOS6.5+mysql5.5源码安装
- crontab 的% 而引发的血案
- linux实战(六)----获取备份时间----实例解析
- linux实战(六)----获取备份时间----实例解析
- VirtualBox安装centos7
- centos7下安装vsftpd与PAM虚拟用户