標籤: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簡單的使用者管理