使用mysql命令授權使用者

2021-06-18 07:26:21 字數 1259 閱讀 9137

預設情況下 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;

mysql 授權 mysql 使用者授權

mysql grant 許可權1,許可權2,許可權n on 資料庫名稱.表名稱 to 使用者名稱 使用者位址 identified by 連線口令 許可權1,許可權2,許可權n代表select,insert,update,delete,create,drop,index,alter,grant,re...

mysql授權使用者許可權 mysql授權使用者許可權

grant 普通資料使用者,查詢 插入 更新 刪除 資料庫中所有表資料的權利。grant select on testdb.to common user grant insert on testdb.to common user grant update on testdb.to common us...

mysql 使用者及授權相關命令

一 登陸 mysql 1.輸入命令 mysql u username p 回車後,輸入密碼。二 建立使用者 命令 create user username host identified by password 例子 create user test localhost identified by ...