mysql基本操作

來源:互聯網
上載者:User

標籤:mysql   sele   connect   修改   highlight   grant   sql   cal   授權   

#存取控制

##登入mysql

mysql -u root -p

##查看所有使用者

select user from mysql.user

##建立使用者

CREATE USER ‘username‘@‘host‘ IDENTIFIED BY ‘password‘;

##刪除使用者

注意必須明確給出該帳號的主機名稱

drop user ‘test‘@‘localhost‘;

##重新命名使用者

rename user ‘test‘@‘localhost‘to‘foo‘@‘localhost‘;

##修改密碼

set password for ‘test‘@‘localhost‘=password(‘hello‘);

#許可權管理

##查看許可權

show grants for ‘test‘@‘localhost‘;

##授權

grant select(cust_id,cust_name)    on mysql_test.customers    to‘zhangsan‘@‘localhost‘;--授予在資料庫mysql_test的表customers上擁有對列cust_id和列cust_name的select許可權

  

grant select ,update    on mysql_test.customers    to ‘liming‘@‘localhost‘identified by‘123‘;--建立一個使用者為liming,並授予其在資料庫mysql_test的表customers上擁有select和update的許可權

  

grant all    on mysql_test.*    to‘zhangsan‘@‘localhost‘;--授予可以在資料庫mysql_test中執行所有操作的許可權

  

grant create user    on *.*    to‘zhangsan‘@‘localhost‘;--授予系統中已存在使用者zhangsan擁有建立使用者的許可權

##許可權的轉移

grant select,update    on mysql_test.customers    to‘zhou‘@‘localhost‘identified by‘123‘    with grant option;

如果上面with子句後面跟的是

max_queries_per_hour count、 
max_updates_per_hour count、 
max_connections_per_hour count、 
max_user_connections count 
中的某一項,則該grant語句可用於限制許可權

grant delete    on mysql_test.customers    to ‘zhangsan‘@‘localhost‘    with max_queries_per_hour 1;--每小時只能處理一條delete語句的許可權

##許可權的撤銷

revoke select     on mysql_test.customers    from‘zhangsan‘@‘localhost‘;--回收使用者zhangsan在資料庫mysql_test的表customers上的select許可權

搬運自http://blog.csdn.net/ParanoidYang/article/details/61951265

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.