mysql开启远程访问权限

时间:2023-01-29 20:19:01
 1. 
//登录数据库
  mysql -u root -pvmwaremysql>use mysql;
  //%为所有ip都可以远程访问
  mysql>update user set host = '%' where user = 'root';
//或直接添加一条语句也行   
mysql>insert into user (host,user,password) values('192.168.0.51','root',password('123'));  
  //查看一下修改
  mysql>select host, user from user;
//推送设置到内存或重启服务器也行
  mysql>FLUSH PRIVILEGES 2.  
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
如果是固定ip就这么写
grant all privileges on *.* to 'root'@'192.168.0.49'identified by '123' with grant option;
//推送设置到内存或重启服务器也行
  mysql>FLUSH PRIVILEGES