1.登录MySQL语句
mysql -h hostname|hostIP -P port -u username -p dbname -e "SQL语句";
2.新建普通用户
CREATE USER username@Host IDENTIFIED BY 'password';
INSERT INTO mysql.user(Host,User,Password)values('hostname','username',PASSWORD('password'));
GRANT priv_type ON database.table TO username@Host IDENTIFIED BY 'password';
注意:mysql用户在没有任何权限的情况下也能建立和修改名为test的数据库
建完后执行 fulsh privileges,否则不能生效;
3.删除普通用户
DROP USER username@Host;
4.root用户修改自己的密码
>mysqladmin -u username -p password new_password
>Enter password:******
UPDATE mysql.user SET Password=PASSWORD('new_password') WHERE User='username' AND Host='Host';
SET PASSWORD=PASSWORD('new_password');
5.root用户修改普通用户的密码
UPDATE mysql.user SET Password=PASSWORD('new_password') WHERE User='username' AND Host='Host';
SET PASSWORD FOR username@hostname=PASSWORD('new_password');
6.普通用户修改自己的密码
SET PASSWORD=PASSWORD('new_password');
7.MySQL权限表