mysql操作筆記

2021-06-21 22:27:49 字數 801 閱讀 7670

user01只能本地訪問

create user user01@'localhost' identified by 'password1';

user02可以遠端訪問

create user user02@'%' identified by 'password1';

建立資料庫

create database 

db01

;修改user01密碼

set password for 'user01'@'localhost' = password('password2');

授權a)、user01管理db01全部許可權

grant all privileges on db01.* to user01;

b)、user02檢視許可權,並修改密碼

grant select on *.* to 'user02'@'%' identified by 'password2';

grant all privileges on *.* to 'root'@'%'identified by 'root_pwd' with grant option;

flush privileges;

執行完後,可以在mysql資料庫user表裡看到新增了一條記錄,並且遠端可以訪問了

revoke all privileges on *.* from'root'@'%';可以看到新增表項裡的許可權都更新為『n』;

這時遠端連線沒有問題,但沒有任何許可權了。如果禁止遠端連線則刪除這條新增的記錄即可.

delete from user where host='%';

mysql操作筆記

一 select user 顯示的為當前使用的 user 及host use mysql select distinct user from user 顯示該資料庫授權登陸的使用者名稱 其實還有 host 的限制 mysql 中新增使用者 新建資料庫 使用者授權 刪除使用者 修改密碼 注意每行後邊都...

mysql李筆記 mysql操作筆記

匯出資料庫 mysqldump u root p r presentation presentation.sql 匯出presentation資料庫中users表 mysqldump u root p presentation users presentation.sql 匯入資料庫 mysql u...

mysql資料庫操作筆記

查詢最後生成的id select session.identity 建立檢視 create view v add friends as select u.userid,u.real name,u.d.college,d.academe,d.speciality,d.init college date...