python中select用法_python中mysql常用用法

查看

查看变量 show variables like 'auto%';

信息输出: echo "select user,host,password from mysql.user" |mysql -uroot -plingxiangxiang

查看库 show databases;

查看都有哪些库 show databases;

查看某个库的表 use db; show tables \G;

查看表的字段 desc tb;

查看建表语句 show create table tb;

当前是哪个用户 select user();

当前库 select database();

查看数据库版本 select version();

查看mysql状态 show status;

查看mysql队列 show processlist;

查询 select count() from mysql.user; select from mysql.db; select * from mysql.db where host like '10.0.%';

查看权限 show grants for root@'localhost';

select from sutdent where group by stdname a, c where a.id = c.组id group by 字段:字段进行分组

select from information_schema.processlist where info is not null;

查看表索引 show index from 表名

增加

创建库 create database db1;

创建表 create table t1 (id int, name char(40) adress varchar(30));

创建普通用户并授权 grant all on . to databases1.user1 identified by '123456';

grant all on db1.to 'user2'@'10.0.2.100' identified by '111222';

grant all on db1. to 'user3'@'%' identified by '231222';insert into tb1 (id,name) values(1,'aming');

插入 update db1.t1 set name='aaa' where id=1;

创建索引 create index 库名_表名_列名1_列名2 (列名1, 列名2)

删除

删除表 drop table db1.t1; 删除表数据,表结构

删除数据库 drop database db1;

delete from table where 条件判断 删除行数据

char(10) 'aaa '定长,给10个字符,只写了3个,其他7个用空格占用

varchar(10) 'aaa' '变长'

修改

修改mysql参数 show variables like 'max_connect%'; set global max_connect_errors = 1000;

更改密码 UPDATE mysql.user SET password=PASSWORD("newpwd") WHERE user='username' ;

清空表 truncate table db1.t1; 只删除表数据,不删除表结构

修复表 repair table tb1 [use frm];

授权超级用户(对所有库所有表有权限,还可以给其他用户设置权限):

grant all privileges on . to 'tangnanbing'@'%' identified by '1qaz@WSX' with grant option;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值