天天看點

mysql 賦給使用者權限 grant all privileges on

網站出現 SQLException: access denied for  @'localhost' (using password: no)

解決辦法   grant all privileges on *.* to joe@localhost identified by '1';

                 flush privileges;

拿  joe    1 登陸

mysql> grant 權限1,權限2,…權限n on 資料庫名稱.表名稱 to 使用者名@使用者位址 identified by ‘連接配接密碼’;

權限1,權限2,…權限n代表select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file等14個權限。

當權限1,權限2,…權限n被all privileges或者all代替,表示賦予使用者全部權限。

當資料庫名稱.表名稱被*.*代替,表示賦予使用者操作伺服器上所有資料庫所有表的權限。

使用者位址可以是localhost,也可以是ip位址、機器名字、域名。也可以用’%'表示從任何位址連接配接。

‘連接配接密碼’不能為空,否則建立失敗。

mysql>grant select,insert,update,delete,create,drop on vtdc.employee to [email protected] identified by ‘123′;

給來自10.163.225.87的使用者joe配置設定可對資料庫vtdc的employee表進行select,insert,update,delete,create,drop等操作的權限,并設定密碼為123。

mysql>grant all privileges on vtdc.* to [email protected] identified by ‘123′;

給來自10.163.225.87的使用者joe配置設定可對資料庫vtdc所有表進行所有操作的權限,并設定密碼為123。

mysql>grant all privileges on *.* to [email protected] identified by ‘123′;

給來自10.163.225.87的使用者joe配置設定可對所有資料庫的所有表進行所有操作的權限,并設定密碼為123。

mysql>grant all privileges on *.* to joe@localhost identified by ‘123′;

給本機使用者joe配置設定可對所有資料庫的所有表進行所有操作的權限,并設定密碼為123。