標籤:ase pen ... revoke lte open global cal 空值
Mysql 常見操作資料庫操作
create database fuzjtest
drop database fuzjtest
show databases
use databas 123123 ###使用者授權
create user ‘使用者名稱‘@‘IP地址‘ identified by ‘密碼‘;
drop user ‘使用者名稱‘@‘IP地址‘;
rename user ‘使用者名稱‘@‘IP地址‘; to ‘新使用者名稱‘@‘IP地址‘;;
set password for ‘使用者名稱‘@‘IP地址‘ = Password(‘新密碼‘)
show grants for ‘使用者‘@‘IP地址‘
grant 許可權 on 資料庫.表 to ‘使用者‘@‘IP地址‘
all privileges 除grant外的所有許可權select 僅查許可權select,insert 查和插入許可權...usage 無存取權限alter 使用alter tablealter routine 使用alter procedure和drop procedurecreate 使用create tablecreate routine 使用create procedurecreate temporary tables 使用create temporary tablescreate user 使用create user、drop user、rename user和revoke all privilegescreate view 使用create viewdelete 使用deletedrop 使用drop tableexecute 使用call和預存程序file 使用select into outfile 和 load data infilegrant option 使用grant 和 revokeindex 使用indexinsert 使用insertlock tables 使用lock tableprocess 使用show full processlistselect 使用selectshow databases 使用show databasesshow view 使用show viewupdate 使用updatereload 使用flushshutdown 使用mysqladmin shutdown(關閉MySQL)super ????使用change master、kill、logs、purge、master和set global。還允許mysqladmin????????調試登陸replication client 伺服器位置的訪問replication slave 由複製從屬使用相關許可權
詳細許可權解釋說明
對於目標資料庫以及內部其他: 資料庫名.* 資料庫中的所有 資料庫名.表 指定資料庫中的某張表 資料庫名.預存程序 指定資料庫中的預存程序 *.* 所有資料庫
針對資料庫進行制授權
使用者名稱@IP地址 使用者只能在改IP下才能訪問使用者名稱@192.168.1.% 使用者只能在改IP段下才能訪問(萬用字元%表示任意)使用者名稱@% 使用者可以再任意IP下訪問(預設IP地址為%)
針對使用者及IP進行授權
grant all privileges on db1.tb1 TO ‘使用者名稱‘@‘IP‘grant select on db1.* TO ‘使用者名稱‘@‘IP‘grant select,insert on *.* TO ‘使用者名稱‘@‘IP‘revoke select on db1.tb1 from ‘使用者名稱‘@‘IP‘
常用執行個體
表操作
create table 表名( 列名 類型 是否可以為空白, 列名 類型 是否可以為空白)
1.是否可空,null表示空,非字串 not null - 不可空 null - 可空2.預設值,建立列時可以指定預設值,當插入資料時如果未主動設定,則自動添加預設值 create table tb1( nid int not null defalut 2, num int not null )3.自增,如果為某列設定自增列,插入資料時無需設定此列,預設將自增(表中只能有一個自增列) create table tb1( nid int not null auto_increment primary key, num int null ) 或 create table tb1( nid int not null auto_increment, num int null, index(nid) ) 注意:1、對於自增列,必須是索引(含主鍵)。 2、對於自增可以設定步長和起始值 show session variables like ‘auto_inc%‘; set session auto_increment_increment=2; set session auto_increment_offset=10; shwo global variables like ‘auto_inc%‘; set global auto_increment_increment=2; set global auto_increment_offset=10; 4.主鍵,一種特殊的唯一索引,不允許有空值,如果主鍵使用單個列,則它的值必須唯一,如果是多列,則其組合必須唯一。 create table tb1( nid int not null auto_increment primary key, num int null ) 或 create table tb1( nid int not null, num int not null, primary key(nid,num) ) 5.外鍵,一個特殊的索引,只能是指定內容 creat table color( nid int not null primary key, name char(16) not null ) create table fruit( nid int not null primary key, smt char(32) null , color_id int not null, constraint fk_cc foreign key (color_id) references color(nid) )
建立表參數
MYSQL常用操作及python操作MYSQL常用類