mysql 用戶授權
默認情況下 mysql 是以root 用戶進入 並且操作的,那麼要想以其他用戶進入並且對數據庫進行增刪改查的工作那麼就需要 以root 用戶的身份進入 給數據庫授權 給 相應的用戶
server0:/usr/local/mysql/bin # mysql -uroot -p
Enter password:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| solrclient |
| test |
+--------------------+
mysql> grant all privileges on solrclient.* to suse@localhost identified by 'suse‘;
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql>\q
還可以進行更細粒度的 授權:
//如果想指定部分權限給一用戶,可以這樣來寫:
mysql>grant select,update on solrDB.* to suse@localhost identified by ‘suse’;
3.刪除用戶
@>mysql -u root -p
@>密碼
mysql>DELETE FROM user WHERE User='suse'and Host=”localhost”;
mysql>flush privileges;
//刪除用戶的數據庫
mysql>drop database solrDB;
4.修改指定用戶密碼
@>mysql -u root -p
@>密碼
mysql>update mysql.user set password=password(‘新密碼’) where User='suse' and Host=”localhost”;
mysql>flush privileges;
mysql>quit;
作者“715356603-qq-com”