MySQL使用者與授權

2021-09-10 18:50:09 字數 2294 閱讀 5637

create user 『username』@『root』 identified by 『password』;

username:你將建立的使用者名稱

– root:指定該使用者在哪個主機上可以登陸,如果是本地使用者可用localhost,如果想讓該使用者可以從任意遠端主機登陸,可以使用萬用字元%

– password:該使用者的登陸密碼,密碼可以為空,如果為空則該使用者可以不需要密碼登陸伺服器

create user 『suniu』@』%』 identified by 『666666』;

grant privileges on databasename.tablename to 『username』『root』;

– privileges:使用者的操作許可權,如select,insert,update等,如果要授予所的許可權則使用all

– databasename:資料庫名

– tablename:表名,如果要授予該使用者對所有資料庫和表的相應操作許可權則可用表示,如.*

grant select on school_db.* to 『suniu』@』%』;

grant privileges on school_db.* to 『suniu』@』%』 with grant option;

set password for 『suniu』@』%』 = password(『new password』);

set password = password(「new password」);

revoke privilege on databasename.tablename from 『username』@『root』;

revoke select on school_db.* from 『suniu』@』%』;

假如你在給使用者』pig』@』%『授權的時候是這樣的(或類似的):grant select on test.user to 『pig』@』%』,

則在使用revoke select on . from 『pig』@』%』;命令並不能撤銷該使用者對test資料庫中user表的select 操作。

相反,如果授權使用的是grant select on . to 『pig』@』%』;則revoke select on test.user from 『pig』@』%』;

命令也不能撤銷該使用者對test資料庫中user表的select許可權。

具體資訊可以用命令show grants for 『pig』@』%』; 檢視。

drop user 『username』@『host』;

推薦:mysql 黑視窗 新增新使用者、為使用者建立資料庫、為新使用者分配許可權

答案:(1).

1、mysql安裝路徑選擇

2、mysql data 資料庫目錄安裝路徑選擇

3、連線數設定

4、設定mysql 密碼

(2).

mysql -u root -p

沒有密碼

mysql -u root -p password

帶密碼登入。

(3).

create table 語句用於建立資料庫中的表。

具體用法為:

create table 表名稱 (列名稱1 資料型別,列名稱2 資料型別,列名稱3 資料型別,)

select from 語句用於檢視表

具體用法為:

select * from 表名 語法中的」*「代表所有。

基本表定義格式

create table 表名(

列名 資料型別 列級完整性約束條件,

列名 資料型別 列級完整性約束條件,

…列名 資料型別 列級完整性約束條件,

表級完整性約束條件);

例項:create table region(/地區表/

regionkey integer primary key, /地區編號/

name char(25), /地區名稱/

comment char(152) /備註/

);create table nation(/國家表/

nationkey integer primary key, /國家編號/

name char(25), /國家名稱/

regionkey integer references region(regionkey), /地區編號/

comment varchar(152) /備註/

);delete from 表名 where user_name

例項:delete from user_info where u_name = 『趙文明』;

(4)、個體與班級就是一對一,華為品牌與商品就是一對多,班級與學生就是多對多

MySQL新增使用者使用者與授權

mysql中新增使用者,新建資料庫,使用者授權,刪除使用者,修改密碼 注意每行後邊都跟個 表示乙個命令語句結束 1.新建使用者 登入mysql mysql u root p 密碼 建立使用者 mysql insert into mysql.user host,user,password values...

mysql 授權 mysql 使用者授權

mysql grant 許可權1,許可權2,許可權n on 資料庫名稱.表名稱 to 使用者名稱 使用者位址 identified by 連線口令 許可權1,許可權2,許可權n代表select,insert,update,delete,create,drop,index,alter,grant,re...

mysql授權使用者許可權 mysql授權使用者許可權

grant 普通資料使用者,查詢 插入 更新 刪除 資料庫中所有表資料的權利。grant select on testdb.to common user grant insert on testdb.to common user grant update on testdb.to common us...