Linux下Mysql常用

來源:互聯網
上載者:User

標籤:

1,查看目前使用者許可權

  select host,password, user from user;

 

2,使用者

  建立使用者

  insert into mysql.user(Host,User,Password,ssl_cipher,x509_issuer,x509_subject) values("Host","User",password("Password"),‘‘,‘‘,‘‘);

  (HOST表示能訪問的IP,如果允許任意IP的話,HOST設定為‘%‘)

  

  修改指定使用者密碼

  update mysql.user set password=password(‘新密碼‘) where User="test" and Host="localhost";

  

  刪除使用者

  delete mysql.user where user=‘User‘ and host="Host";

 

3,賦予許可權

  grant all privileges on databaseNm.tableNm to ‘User‘@‘Host‘ identified by ‘Password‘;

  *:加上with grant option讓授權的使用者,也可以將這些許可權 grant 給其他使用者一般很少使用;

 

  取消許可權

  revoke all privileges on databaseNm.tableNm from User;

  

4,重新整理許可權

  flush privileges;

 

5,許可權表

  user表 user表列出可以串連伺服器的使用者及其口令,並且它指定他們有哪種全域(超級使用者)許可權。在user表啟用的任何許可權均是全域許可權,並適用於所有資料庫。例如,如果你啟用了DELETE許可權,在這裡列出的使用者可以從任何錶中刪除記錄,所以在你這樣做之前要認真考慮。

  db表 db表列出資料庫,而使用者有許可權訪問它們。在這裡指定的許可權適用於一個資料庫中的所有表。

  host表 host表與db表結合使用在一個較好層次上控制特定主機對資料庫的存取權限,這可能比單獨使用db好些。這個表不受GRANT和REVOKE語句的影響,所以,你可能發覺你根本不是用它。

  tables_priv表 tables_priv表指定表級許可權,在這裡指定的一個許可權適用於一個表的所有列。

  columns_priv表 columns_priv表指定列級許可權。這裡指定的許可權適用於一個表的特定列。

 

6,privileges
  alter:修改資料庫的表
  create:建立新的資料庫或表
  delete:刪除表資料
  drop:刪除資料庫/表
  index:建立/刪除索引
  insert:添加表資料
  select:查詢表資料
  usage:只允許登入
  all:允許任何操作
  update:更新表資料

 

7,備份資料庫

  mysqldump -h IP -uusername -ppassword databasename --add-drop-database > /var/tmp/test.sql

  還原的話將>改為<即可。

Linux下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.