修改root账号 root qwer123 use mysql; update mysql.user set authentication_string=password('qwer123') where user='root' ; GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'qwer123' WITH GRANT OPTION; flush privileges; use mysql; drop user root@'%'; update mysql.user set authentication_string=password('qwer123') where user='root' ; flush privileges; 创建应用账号: teachinguser qwer123 use mysql; CREATE USER 'teachinguser'@'10.10.10.%' IDENTIFIED BY 'qwer123'; CREATE USER 'teachinguser'@'localhost' IDENTIFIED BY 'qwer123'; grant all privileges on basedata.* to teachinguser@'10.10.10.%'; grant all privileges on basedata.* to teachinguser@'localhost'; flush privileges; 创建只读账号: rouser qwer123 use mysql; CREATE USER 'rouser'@'10.10.10.%' IDENTIFIED BY 'qwer123'; CREATE USER 'rouser'@'localhost' IDENTIFIED BY 'qwer123'; grant select on *.* to rouser@'10.10.10.%'; grant select on *.* to rouser@'localhost'; flush privileges; 创建DBA账号: dbauser qwer123 use mysql; CREATE USER 'dbauser'@'10.10.10.%' IDENTIFIED BY 'qwer123'; CREATE USER 'dbauser'@'localhost' IDENTIFIED BY 'qwer123'; grant all privileges on *.* to dbauser@'10.10.10.%' WITH GRANT OPTION; grant all privileges on *.* to dbauser@'localhost' WITH GRANT OPTION; flush privileges;