mysql新增使用者 Mysql新增使用者與授權

2021-10-25 14:14:30 字數 1203 閱讀 1846

1、本地環境

centos linux release 7.5.1804 (core)

2、以root使用者登入mysql

mysql -uroot -proot

3、切換到mysql資料庫

use mysql

4、新增使用者

//只允許指定ip連線

create user '新使用者名稱'@'localhost' identified by '密碼';

//允許所有ip連線(用萬用字元%表示)

create user '新使用者名稱'@'%' identified by '密碼';

5、為新使用者授權

//基本格式如下

grant all privileges on 資料庫名.表名 to '新使用者名稱'@'指定ip' identified by '新使用者密碼' ;

//示例

//允許訪問所有資料庫下的所有表

grant all privileges on *.* to '新使用者名稱'@'指定ip' identified by '新使用者密碼' ;

//指定資料庫下的指定表

grant all privileges on test.test to '新使用者名稱'@'指定ip' identified by '新使用者密碼' ;

6、設定使用者操作許可權

//設定使用者擁有所有許可權也就是管理員

grant all privileges on *.* to '新使用者名稱'@'指定ip' identified by '新使用者密碼' with grant option;

//擁有查詢許可權

grant select on *.* to '新使用者名稱'@'指定ip' identified by '新使用者密碼' with grant option;

//其它操作許可權說明,select查詢 insert插入 delete刪除 update修改

//設定使用者擁有查詢插入的許可權

grant select,insert on *.* to '新使用者名稱'@'指定ip' identified by '新使用者密碼' with grant option;

//取消使用者查詢的查詢許可權

revoke select on what from '新使用者名稱';

7、刪除使用者

drop user username@localhost;

8、修改後重新整理許可權

flush privileges;

mysql使用者新增 MySQL使用者新增

我的是ubuntu 12.04。發現在mysql中經常出現新增使用者之後,要麼只能本地登陸,要麼只能遠端登陸的蛋疼的情況。這裡記錄一下是如何操作的。建立使用者 create user username identified by password 如果想要讓這個使用者即可以本地登陸,也可以遠端登 我...

mysql使用者新增 mysql新增使用者

mysql新增使用者 mysql新增使用者方法 建立資料庫gamesp create database gamesp 新增使用者 grant all on 資料庫名.to 使用者 名 localhost identified by 密碼 grant all on gamesp.to newuser ...

mysql新增 mysql新增使用者

增加新使用者 格式 grant select on 資料庫.to 使用者名稱 登入主機 identified by 密碼 例1 增加乙個使用者test1密碼為abc,讓他可以在任何主機上登入,並對所有資料庫有查詢 插入 修改 刪除的許可權。首先用以root使用者連入mysql,然後鍵入以下命令 gr...