1.添加新用戶
只允許本地IP訪問
1
|
create user 'test' @ 'localhost' identified by '123456' ; |
允許外網IP訪問
1
|
create user 'test' @ '%' identified by '123456' ; |
刷新授權
1
|
flush privileges ; |
2.為用戶創建數據庫
1
|
create database test DEFAULT CHARSET utf8 COLLATE utf8_general_ci; |
3.為用戶分配權限
授予用戶通過外網IP操作該數據庫的所有去權限
1
|
grant all privileges on `testdb`.* to 'test' @ '%' identified by '123456' ; |
授予用戶通過外網IP操作所有數據庫的權限
1
|
grant all privileges on *.* to 'test' @ '%' identified by '123456' ; |
刷新授權
1
|
flush privileges ; |
到此這篇關于MySql添加新用戶及為用戶創建數據庫和給用戶分配權限方法介紹的文章就介紹到這了,更多相關MySql添加新用戶為用戶創建數據庫和給用戶分配權限內容請搜索服務器之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持服務器之家!
原文鏈接:https://blog.csdn.net/weixin_38981118/article/details/80467970