mysql數據庫 登錄,mysql怎么給數據庫添加用戶?
1、用管理員登陸mysql
2、創建數據庫create database db01;
3、創建用戶
user01只能本地訪問
CREATE USER user01@'localhost' IDENTIFIED BY 'password1';
user02可以遠程訪問
CREATE USER user02@'%' IDENTIFIED BY 'password1';
4、修改user01密碼
SET PASSWORD FOR 'user01'@'localhost' = PASSWORD('password2');
5、授權
a)、user01管理db01全部權限
GRANT ALL PRIVILEGES ON db01.* TO user01;
b)、user02查看權限,并修改密碼
GRANT SELECT ON *.* TO 'user02'@'%' IDENTIFIED by 'password2';