MySQL簡單的使用者管理

來源:互聯網
上載者:User

標籤:mysql

mysql安裝後的一點安全性原則就是刪除空使用者和host不為localhost的使用者

1、刪除空使用者

刪除空使用者

mysql> select mysql.user,host,password from user whereuser=‘‘;    查詢使用者

mysql> delete from user where user=‘‘;        #刪除user=空的使用者

刪除host不等於localhost的使用者

mysql> select user,host,password from user where host!=‘localhost‘;

mysql>delete from user where host!=’localhost’;

2、為使用者佈建密碼

mysql> update user set password=password(123456);

mysql>flush privileges;

建立mysql使用者及賦予使用者權限

1.建立使用者並設定密碼

mysql>create user [email protected]’localhost’ identified by‘123456’;

mysql>create user [email protected]’localhost’;

 

2.常用的建立使用者方法;建立使用者的同時並進行授權 grant

mysql> grant all on blog.* to ‘acbuf‘@‘localhost‘ identified by ‘123456‘; #不會自動建立blog庫

 

3.為已有使用者授權庫。

mysql> grant all on blog.* to [email protected]‘localhost‘;

 

4.查看使用者權限

mysql>show grants for [email protected]’localhost’;

 

5.root密碼忘記重新設定密碼

1.編輯/etc/my.cnf在[mysqld]段中添加skip-grant-tables,然後重啟mysqld。

然後mysql進入即可,然後update為root設定密碼

,設定完成後把添加的skip-grant-tables刪除重啟即可。

2.[[email protected] /]# mysqld_safe--skip-grant-tables --user=mysql  &

後續步驟跟第一個方法一樣。

本文出自 “董書豪” 部落格,請務必保留此出處http://dongshuhao.blog.51cto.com/13042423/1945965

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.