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