Common usage of MySQL in Python

Source: Internet
Author: User

View

View variables show variables like ' auto% ';
Information output: echo "Select User,host,password from Mysql.user" |mysql-uroot-plingxiangxiang
View Gallery show databases;
See which libraries show databases;
View the table of a library use DB; Show Tables \g;
View the table's fields desc TB;
View the Build Table statement show create TABLE TB;
Which user is currently Select users ();
Current Library 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 [email protected] ' localhost ';

Select from sutdent where group by Stdname A, c where a.id = C. Group ID groups by field: field group
Select
from information_schema.processlist where info is not null;
View Table index show index from table name

Increase

Creating a library Create database db1;
CREATE TABLE t1 (id int, name char (+) adress varchar (30));
Create a regular user and authorize 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;
Creating indexes Create Index Library Name _ Table name _ Column name 1_ column name 2 (column name 1, column name 2)

Delete

Delete tables drop table db1.t1; Delete table data, table structure
Delete database drop databases db1;
Delete from table where condition to determine row data deletion
char (x) ' AAA ' fixed length, give 10 characters, write only 3, the other 7 are occupied with a space
varchar (TEN) ' AAA ' to ' grow longer '

Modify

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 tables truncate TABLE db1.t1; Delete table data only, do not delete table structure
Fix tables Repair table tb1 [use frm];

Grant Superuser (Permissions to all tables in all libraries and to other users):
Grant all privileges the ' tangnanbing ' @ '% ' identified by ' [email protected] ' with GRANT option;

Common usage of MySQL in Python

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.