mysql 使用者及授權相關命令

2021-09-13 09:31:36 字數 779 閱讀 7111

一、登陸 mysql

1. 輸入命令:  mysql -u username -p 。回車後,輸入密碼。

二、建立使用者

命令:create user '

username'@'host' identified by 'password';

例子: create user 'test'@'localhost' identified by 'test';

三、為使用者授權

命令:grant privileges on databasename.tablename to 'username'@'host'

ps: privileges - 使用者的操作許可權,如select , insert , update 等(詳細列表見該文最後面).如果要授予所的許可權則使用all.;databasename - 資料庫名,tablename-表名,如果要授予該使用者對所有資料庫和表的相應操作許可權則可用*表示, 如*.*.

四、取消使用者授權

revoke privileges on dbname.* from 'username'@'host';

五、設定與更改使用者密碼

命令:set password for 'username'@'host' = password('newpassword');

例子: set password for '

test2'@'localhost' = password("test2");

mysql管理使用者 使用者授權的相關命令

建立新使用者 以下命令可以建立乙個mysql的本地使用者,無法遠端訪問 create user username localhost identified by password 以下命令可以建立乙個mysql遠端連線使用者 create user username identified by pa...

MySql建立使用者及授權

grant 語句的語法如下 grant privileges columns on what to user identifiedby password with grant option 對使用者授權 mysql grant rights on database.to user host iden...

mysql建立使用者及授權

grant 語句的語法如下 grant privileges columns on what to user identifiedby password with grant option 對使用者授權 mysql grant rights on database.to user host iden...