mysql 賬戶操作

2022-08-27 02:12:10 字數 2273 閱讀 7873

mysql> grant 許可權1,許可權2,…許可權n on 資料庫名稱.表名稱 to 使用者名稱@使用者位址 identified by 『連線口令』;

許可權1,許可權2,…許可權n代表select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file等14個許可權。

當許可權1,許可權2,…許可權n被all privileges或者all代替,表示賦予使用者全部許可權。

當資料庫名稱.表名稱被*.*代替,表示賦予使用者操作伺服器上所有資料庫所有表的許可權。

使用者位址可以是localhost,也可以是ip位址、機器名字、網域名稱。也可以用』%』表示從任何位址連線。

『連線口令』不能為空,否則建立失敗。

例如:mysql>grant select,insert,update,delete,create,drop on vtdc.employee [email protected] identified by 『123′;

給來自10.163.225.87的使用者tanzuai分配可對資料庫vtdc的employee表進行select,insert,update,delete,create,drop等操作的許可權,並設定口令為123。

mysql>grant all on vtdc.* to [email protected] identified by 『123′;

給來自10.163.225.87的使用者tanzuai分配可對資料庫vtdc所有表進行所有操作的許可權,並設定口令為123。

mysql>grant all on *.* to [email protected] identified by 『123′;

給來自10.163.225.87的使用者tanzuai分配可對所有資料庫的所有表進行所有操作的許可權,並設定口令為123。

mysql>grant all privileges on *.* to tanzuai@localhost identified by 『123′;

給本機使用者tanzuai分配可對所有資料庫的所有表進行所有操作的許可權,並設定口令為123。

//如果想指定部分許可權給一使用者,可以這樣來寫:

mysql>grant select,update on tanzuaidb.* to tanzuai@localhostidentified by123456;

//重新整理系統許可權表。

mysql>flush privileges;

eg://登入mysql(有root許可權)。我裡我以root身份登入.

@>mysql -u root -p

@>密碼

//首先為使用者建立乙個資料庫(tanzuaidb)

mysql>create database tanzuaidb;

//授權jeecn使用者擁有jeecn資料庫的所有許可權

@>grant all on tanzuaidb.* to tanzuai@localhostidentified by'123456';

//重新整理系統許可權表

mysql>flush privileges;

mysql>其它操作

@>mysql -u root -p

@>密碼

mysql>delete from user where user=」jeecn」 and host=」localhost」;

mysql>flush privileges;

//刪除使用者的資料庫

mysql>drop database tanzuaidb;

mysql>update mysql.user set password=password(『新密碼』) where user=」tanzuai」 and host=」localhost」;

mysql>flush privileges;

mysql 賬戶 mysql 賬戶管理

mysql增加新使用者賬戶 可以用兩種方式建立mysql賬戶 1.使用grant語句 2.直接操作mysql授權表 最好的方法是使用grant語句,因為這樣更精確,錯誤少。建立超級 使用者 mysql grant all privileges on to monty localhost identi...

mysql 賬戶管理 MySQL賬戶管理

登陸 退出mysql伺服器 登陸mysql伺服器時,可以使用mysql命令並在後面指定登陸主機以及使用者名稱和密碼。mysql命令的常用引數如下 h主機名,該引數指定主機名或ip,如果不指定,預設是localhost。u使用者名稱,該引數指定使用者名稱。p密碼,該引數指定登陸密碼。如果該引數後面有欄...

MySQL 常用賬戶管理及授權操作

適用 mysql5.7 系列,mysql的許可權控制可以做到很細 具體到表 不過 咱 不做 dba,故只列出常用的基本操作。重新整理資料到硬碟 及永久儲存 flush privileges 檢視賬戶 account 的許可權 show grants for account 查詢表 user 結構 s...