Common usage of mysql in python

Check

View variables show variables like 'auto%';
information output: echo "select user,host,password from mysql.user" |mysql -uroot -plingxiangxiang
view libraries show databases;
view which libraries are there show databases;
view a database Table use db; show tables \G;
view table fields desc tb;
view table creation statement show create table tb;
current user select user();
current database select database();
view database version select version();
view mysql status show status;
view mysql queue show processlist;
query select count( ) from mysql.user; select from mysql.db; select * from mysql.db where host like '10.0.%';
view permissions show grants for root@' localhost';

select from sutdent where group by stdname a, c where a.id = c. group id group by field: field is grouped
select
from information_schema.processlist where info is not null;
view table index show index from table name

Increase

Create database create database db1;
create table create table t1 (id int, name char(40) adress varchar(30));
create ordinary user and grant 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 ');
insert update db1.t1 set name='aaa' where id=1;
create index create index library name_table name_column name 1_column name 2 (column name 1, column name 2)

delete

delete table drop table db1.t1; delete table data, table structure
delete database drop database db1;
delete from table where condition judgment delete row data
char(10) 'aaa 'fixed length, given 10 characters, only 3 are written, The other 7 use spaces to occupy
varchar(10) 'aaa' 'longer'

Revise

Modify mysql parameters show variables like 'max_connect%'; set global max_connect_errors = 1000;
change password UPDATE mysql.user SET password=PASSWORD("newpwd") WHERE user='username' ;
empty table truncate table db1.t1; delete only table Data, do not delete table structure
repair table repair table tb1 [use frm];

Authorize super user (has permissions to all tables in all libraries, and can also set permissions for other users):
grant all privileges on . to 'tangnanbing'@'%' identified by '1qaz@WSX' with grant option;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325947325&siteId=291194637