Python基礎——複習、MySQL的操做(0505)

1、正則的複習html

一、[^}]*       不是}這個符號的0個或者多個mysql

二、<html>hello world </html>       正則的寫法 (?P<tag>\w+)>(.*)</(?P=tag)>sql

三、非貪婪匹配   .*?數據庫

四、匹配字幕   [a-zA-Z]            匹配數字   \dide

五、^[] 與 [^] 的區別編碼

2、數據庫 MySQL.net

一、Python的  DB-API 爲大多數數據庫提供了接口。使用流程爲:①引入API模塊;②獲取與數據庫的鏈接;③執行SQL語句和存儲過程;④關閉數據庫鏈接。插件

二、Python 3 安裝MySQL數據庫軟件:使用  pip install pymysql日誌

     

三、mysql 的事物:htm

     事務是必須知足4個條件(ACID): Atomicity(原子性)、Consistency(穩定性)、Isolation(隔離性)、Durability(可靠性)。

    ①事務的原子性:一組事務,要麼成功;要麼撤回。例如一次處理200個事物,有一個失敗,就會撤回該任務。

    ②穩定性 : 有非法數據(外鍵約束之類),事務撤回。

    ③隔離性:事務獨立運行。一個事務處理後的結果,影響了其餘事務,那麼其餘事務會撤回。事務的100%隔離,須要犧牲速度

    ④可靠性:軟、硬件崩潰後,InnoDB數據表驅動會利用日誌文件重構修改。可靠性和高速度不可兼得, innodb_flush_log_at_trx_commit選項 決定何時吧事務保存到日誌裏。

四、推薦的MySQL插件:方便鏈接各類數據庫。  

五、受權超級用戶  with grant option

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

六、查看庫  show datebase

七、查看都有哪些庫    show  datebases

八、查看某個庫的表   use db;show tables \G;

九、查看錶的字段 desc tb;

     查看建表語句 show create table tb;

     當前是哪一個用戶  select user();

     當前庫 select database();

     建立庫 create database db1;

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

     查看數據庫版本 select version();

     查看mysql狀態 show status;

     修改mysql參數 show variables like 'max_connect%'; set global max_connect_errors = 1000;

     查看mysql隊列 show processlist;

十、建立普通用戶並受權 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 mysql.user SET password=PASSWORD("newpwd") WHERE user='username' ;  

十二、查詢 select count(*) from mysql.user; select * from mysql.db;

              select * from mysql.db where host like '10.0.%';

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

     清空表 truncate table db1.t1;

     刪除表 drop table db1.t1;

     刪除數據庫 drop database db1;

     修復表 repair table tb1 [use frm];

1四、查看權限show grants for root@'localhost';

1五、鏈接 MySQL 時須要使用的參數信息

     host:數據庫主機名.默認是用本地主機

     port:MySQL服務使用的TCP端口.默認是3306,數字類型

     user:數據庫登錄名.默認是當前用戶

     passwd:數據庫登錄的密碼.默認爲空

     db:要使用的數據庫名.沒有默認值

     charset:數據庫編碼

相關文章
相關標籤/搜索