mysql 使用者/密碼/許可權操作

來源:互聯網
上載者:User

標籤:lin   指定   連結   variable   key   kill   syntax   trigger   targe   

由於最近使用mysql遇到了修改使用者密碼的問題,所以一塊學習了一下關於使用者的相關操作;

1. 建立新賬戶

CREATE USER ‘jeffrey‘@‘localhost‘;

 

  

2. 賬戶設定密碼

#目前使用者設定密碼SET PASSWORD = PASSWORD(‘mypass‘);#給指定賬戶設定密碼SET PASSWORD FOR ‘jeffrey‘@‘localhost‘ = PASSWORD(‘mypass‘);

 

 

3. 給賬戶賦許可權

#賦許可權GRANT ALL ON db1.* TO ‘jeffrey‘@‘localhost‘;#重新整理許可權flush privileges;

  

  重新整理許可權的方式有多種,如上只是其中的一種方式。詳情點擊 或 如下:

 

 

    可賦值的許可權如下表:

 

Table 13.3 Permissible Privileges for GRANT and REVOKE

Privilege Meaning and Grantable Levels
ALL [PRIVILEGES] Grant all privileges at specified access level except GRANT OPTION and PROXY.
ALTER Enable use of ALTER TABLE. Levels: Global, database, table.
ALTER ROUTINE Enable stored routines to be altered or dropped. Levels: Global, database, procedure.
CREATE Enable database and table creation. Levels: Global, database, table.
CREATE ROUTINE Enable stored routine creation. Levels: Global, database.
CREATE TABLESPACE Enable tablespaces and log file groups to be created, altered, or dropped. Level: Global.
CREATE TEMPORARY TABLES Enable use of CREATE TEMPORARY TABLE. Levels: Global, database.
CREATE USER Enable use of CREATE USERDROP USERRENAME USER, and REVOKE ALL PRIVILEGES. Level: Global.
CREATE VIEW Enable views to be created or altered. Levels: Global, database, table.
DELETE Enable use of DELETE. Level: Global, database, table.
DROP Enable databases, tables, and views to be dropped. Levels: Global, database, table.
EVENT Enable use of events for the Event Scheduler. Levels: Global, database.
EXECUTE Enable the user to execute stored routines. Levels: Global, database, table.
FILE Enable the user to cause the server to read or write files. Level: Global.
GRANT OPTION Enable privileges to be granted to or removed from other accounts. Levels: Global, database, table, procedure, proxy.
INDEX Enable indexes to be created or dropped. Levels: Global, database, table.
INSERT Enable use of INSERT. Levels: Global, database, table, column.
LOCK TABLES Enable use of LOCK TABLES on tables for which you have the SELECT privilege. Levels: Global, database.
PROCESS Enable the user to see all processes with SHOW PROCESSLIST. Level: Global.
PROXY Enable user proxying. Level: From user to user.
REFERENCES Enable foreign key creation. Levels: Global, database, table, column.
RELOAD Enable use of FLUSH operations. Level: Global.
REPLICATION CLIENT Enable the user to ask where master or slave servers are. Level: Global.
REPLICATION SLAVE Enable replication slaves to read binary log events from the master. Level: Global.
SELECT Enable use of SELECT. Levels: Global, database, table, column.
SHOW DATABASES Enable SHOW DATABASES to show all databases. Level: Global.
SHOW VIEW Enable use of SHOW CREATE VIEW. Levels: Global, database, table.
SHUTDOWN Enable use of mysqladmin shutdown. Level: Global.
SUPER Enable use of other administrative operations such as CHANGE MASTER TOKILLPURGE BINARY LOGSSET GLOBAL, and mysqladmin debug command. Level: Global.
TRIGGER Enable trigger operations. Levels: Global, database, table.
UPDATE Enable use of UPDATE. Levels: Global, database, table, column.
USAGE Synonym for “no privileges”

 

 4. 常用mysql命令

#查看目前使用者select current_user;select current_user();#格式化輸出結果 字元/G 代表格式化輸出select * from t where t.id = 1/G;

 

 

5. 參考連結

  1.  https://dev.mysql.com/doc/refman/5.6/en/set-password.html

  2. https://dev.mysql.com/doc/refman/5.7/en/create-user.html#create-user-previous

  3. https://dev.mysql.com/doc/refman/5.6/en/grant.html

  4. https://dev.mysql.com/doc/refman/5.7/en/privilege-changes.html

  

mysql 使用者/密碼/許可權操作

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.