编程爱好者之家
开启远程访问:
- 更新用户
use mysql;
update user set host = "%" where user = "root";
flush privileges;
- 添加用户
use mysql;
insert into user(host, user, password) values("%", "root", password("yourpassword"))
grant all privileges on *.* to 'root'@'%' with grant option #赋予任何主机访问数据库权限
flush privileges;
关闭远程访问:
use mysql;
update user set host = "localhost" where user = "root" and host= "%";
flush privileges;
查看用户权限:
use information_schema;
select * from user_privileges;
查看当前mysql用户:
use mysql;
select user, host from user;
更新用户:
update mysql.user set password=password('新密码') where User="phplamp" and Host="localhost";
flush privileges;
删除用户:
DELETE FROM user WHERE User="phplamp" and Host="localhost";
flush privileges;