Mysql建立使用者並授權

2022-03-17 20:51:07 字數 931 閱讀 8127

mysql -uroot -p

登入mysql

use mysql;

建立使用者:

create user 'test123'@'localhost' identified by '12345';

這裡的test123表示user,localhost表示host,12345表示authentication_string(密碼)

授權:

grant all privileges on *.* to 'test123'@'localhost';

這裡的*.* 可以改成 testdb.*,testdb 表示具體的某乙個庫,testdb.*表示 testdb庫的所有表

這裡的all privileges表示所有許可權,許可權分為:select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file等14個許可權

所以這裡也可以這樣授權:

grant select,insert,update,delete on *.* to 'test123'@'localhost';

grant select,insert,update,delete,create,alter,drop on testdb.* to 'test123'@'localhost';

撤消授權:

revoke all on *.* from 'test123'@'localhost';

重新整理:

flush privileges;

做完增刪改之後都要記得重新整理授權

檢視使用者操作許可權:

show grants for'test123'@'localhost';

MySql建立使用者並授權

本文簡單描述如何在mysql下完成使用者的建立授權等操作 登陸mysql 使用root使用者登陸mysql jacky gentoo mysql uroot p xx xx代表各自的密碼 mysql create user pysite localhost identified by xx 自此完成...

MySQL 建立使用者並授權

create user username host identified by password 說明 示例 create user jack localhost identified by 123456 create user rose 192.168.38.110 idendified by 1...

mysql建立使用者並授權

create database db create user user identified by pwd grant all privileges on db to user create user user admin identified by pwd grant select,insert,...