重新瞭解數據庫——數據庫用戶管理和備份

用戶管理

創建用戶

create user 用戶名 identidied by '密碼';

修改當前用戶密碼

set password = password('密碼');

修改指定用戶密碼

set password for 用戶名 = password('密碼');

重命名

rename user 舊名字 to 新名字;

用戶授權 all privileges 全部的權限除了授權  庫.表

grant all privileges on *.* to 用戶名;

查詢權限

show grants for 用戶;

show grants for root@localhost;

撤銷權限

revoke all procoleges on *.* from 用戶;

刪除用戶

drop user kuangshen;

 

數據庫備份

使用命令行導出

mysqldump -hlocalhost -u 用戶名 -p 密碼 數據庫 表名 表名 .. > 物理磁盤位置/文件名

導入

登陸過的切換到指定數據庫導入

source d:/a.sql

這樣就可以把sql文件導入到數據庫啦。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章