mysql 給其他用戶賦值 數據庫權限


登陸root或者管理員用戶

#test 數據庫用戶名
#testpassword 數據庫密碼
#創建允許遠程訪問的用戶 create user test@
'%' identified by 'testpassword';
#執行成功之后刷新用戶權限
flush privileges;

執行

#admin_v6 為數據庫名稱
grant all privileges on admin_v6.* to "test"@"%" identified by "testpassword" with grant option;

#執行成功之后刷新用戶權限
flush privileges;

 

 

允許mysql用戶遠程訪問

注:只支持mysql 8.0之前的版本

grant all on *.* to test@'%' identified by '你的密碼' with grant option;
flush privileges;

%表示允許任何ip地址

賬戶如果不存在的話會創建

mysql 8.0之后的版本

grant all privileges on *.* to test@'%' with grant option;

#使用navicat連接mysql 8.0 密碼加密規則問題,錯誤碼【1251】
ALTER USER 'test'@'%' IDENTIFIED WITH mysql_native_password BY '你的密碼';
  
 
        

 

 

刪除用戶

drop user 'test'@'%';

 

查詢所有用戶

SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM