解决mysql只能使用localhost方式连接,不能使用ip方式连接

来源:互联网 发布:java马士兵整套视频 编辑:程序博客网 时间:2024/05/16 17:47

首先进入命令提示符,进入到mysql的安装目录,默认为:(C:\Program Files\MySQL\MySQL Server 5.6\bin)

cd  C:\Program Files\MySQL\MySQL Server 5.6\bin

1. 命令行进入mysql(假设root用户的密码也为root)

mysql -hlocalhost -uroot -proot

2. 使用mysql数据库

use mysql;

3. 赋予权限

grant all privileges on *.*  to  'root’@'%’ identified by  'root’;

其中*.*的意思是 所有库.所有表, 'root'@'%' identified by 'root'的前一个root是用户名,%是指所有访问ip,后一个root是指密码。

grant all privileges on *.*  to  'root'  @'192.168.160.101' identified by 'root';(注意单引号,中英文切换)

4. 刷新权限(在不重启的情况下生效)

flush privileges;

听说实际实现方式是将user和privilige表里的东西扔进内存。

5. 重启mysql服务

其实不用,但我们可以严肃地走个仪式


阅读全文
0 0