1.set password for 用户名@ip = password(‘新密码’);
例:set password for changxiao@localhost =password(‘123456’);
2.mysqladmin -u用户名 -p旧密码 password 新密码;
例:mysqladmin -uchangxiao -p123 password 123456;
3.update mysql.user set authentication_string=password(‘新密码’) where user='用户名 ';
**
创建新用户与限制IP登录
**
create user ‘用户名’@‘ip’ identified by ‘密码‘
例:create user ‘root’@’%’ identified by ‘123’;(%代表任何主机都可访问)
create user ‘用户名’@‘120.%.%.%’ identified by '密码‘这就是只有IP=120开头的地址才能登录,限制IP登录。
库表授权与回收
授权语法
1.grant 权限1,权限2…on数据库对象 to ‘用户’.
如果用户并不存在则创建并授权如下所示:
grant 权限1,权限2…on数据库对象 to ’用户‘@’ip‘ identified by ’password‘;
回收授权
revork 权限1,权限2…on数据库对象 from’用户‘@’ip‘;