資料庫學習筆記十六 許可權管理和備份

2021-10-05 23:00:13 字數 1295 閱讀 1904

參考教程b站狂神

-- 建立使用者

-- create user 使用者名稱 identified by '登入密碼'

create

user ylw identified by

'123456'

-- 修改密碼(修改當前使用者密碼)

set password = password(

'123456'

)-- 修改密碼(修改指定使用者密碼)

set password for ylw = password(

'123456'

)-- 給使用者重新命名

-- rename user 原來的名字 to 新的名字

rename

user ylw to ylw2

-- 使用者授權 all privileges 全部的許可權,庫,表,*.*所有的庫里所有的表

-- all privileges許可權,除了給別人授權,其他都能幹

grant

allprivilegeson*

.*to ylw2

-- 查詢許可權

show grants for ylw2 -- 檢視指定使用者的許可權

show grants for root@localhost

-- 檢視root使用者的許可權

-- 撤銷許可權

-- revoke 哪些許可權 on 資料庫.表 from 使用者名稱

revoke

allprivilegeson*

.*from ylw2

-- 刪除使用者

-- drop user 使用者名稱

drop

user ylw

為什麼要備份:

mysql資料庫備份的方式

格式

mysqldump -h主機 -u使用者名稱 -p密碼 資料庫名 表名 >匯出目錄/檔名

例如mysqldump -hlocalhost -uroot -p123 school student >d:/a.sql

只匯出資料庫的話,就不用寫表名了

匯出多個表

mysqldump -h主機 -u使用者名稱 -p密碼 資料庫名 表1 表2 表3 >匯出目錄/檔名

1.先登入進mysql

2.然後use 資料庫;(匯入表的話要使用資料庫,匯入資料庫直接匯入就行)

3.然後輸入命令

source 檔案目錄

不登入的話

mysql -u使用者名稱 -p密碼 資料庫名 < 要匯入的檔案目錄

資料庫許可權管理和維護

1 賦許可權 1 對普通使用者的查詢刪除grant select,insert,update,delete,execute on database.to user hostname identifiedby password 2 對資料庫開發人員需要許可權 create 建立 alter 修改 dr...

資料庫 許可權管理

許可權管理,授權操作只能以root操作 select from mysql.user g 檢視擁有user許可權的使用者 create user 使用者名稱 localhost identified by 密碼 新增之後再檢視就有了。預設造出來的在user表裡沒有任何許可權。select from ...

資料庫 許可權管理

建立賬號 create user mpd localhost identified by 123 mysql umpd p123 可以在本地登陸 create user nicexm identified by 123 h 服務端ip 可以遠端連線mysql伺服器 給使用者授權 user 許可權最高...