MySQL允许root远程访问

时间:2023-03-09 15:48:33
MySQL允许root远程访问

1. mysql -u root -p;     // 登录mysql, 并输入密码

2. use mysql;             // 打开 mysql 数据库

3. update user set host='%' where user='root' and host='localhost';     // 允许远程登录

update user set host='localhost' where user='root';  //  禁止远程登录

4. flush privileges;    //刷新权限表,使配置生效

5. service mysqld restart  // 重启mysql服务