MySql 只能访问localhost 和 127.0.0.1访问 不能经过其余IP访问

问题描述:mysql

项目中跨域请求数据,在远程主机访问本机的MySql时,老是没法链接。本机也只能用localhost和127.0.0.1访问,不能够用192.168.*.*等IP访问。

解决方案:sql

1.以root用户登录mysql数据库数据库

mysql -u root -p

2.执行一下命令分配新用户跨域

grant all privileges on *.* to root@'%' identified by 'your root password'; 添加成功以后返回信息:Query OK, 0 rows affected (0.03 sec)

'all privileges ':全部权限 也能够写成 select ,update等。

*.* 全部库的全部表 如 databasename.*。

IP  数据库所在的IP。

identified by ‘密码’ 表示经过密码链接

3.执行完上述命令后用下面的命令刷新一下权限ide

flush privileges;

4.修改my.conf配置code

[mysqld] ... bind_address=127.0.0.1 # 屏蔽掉该处 ...

5.从新启动mysql配置

启动:输入 net stop mysql

中止:输入 net start mysql
相关文章
相关标签/搜索