mysql运行远程连接:
第一步:登录msyql:
第二步:use mysql;
第三步:执行如下命令
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'admin' WITH GRANT OPTION;
操作完后切记执行以下命令刷新权限
mysql>FLUSH PRIVILEGES;
查看修改后的用户信息
mysql>select host,user,password from user;
如果密码设置错了,用下面的方法修改;
修改密码;
mysql> update user set password = 'admin' where user = '%';
>mysql -h localhost -u root -padmin
命令行下连接远程数据库:
>mysql -h 192.168.0.201 -P 3306 -u root -padmin
附录:
删除匿名用户:
delete from user where user='';
增加允许远程访问的用户或者允许现有用户的远程访问
注意修改(防火墙)[https://www.jianshu.com/p/7a79c5da6dcb]设置
mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
退出数据库
mysql> exit