重新安装mysql数据库遇到个问题,通过localhost或者127.0.0.1可以连接,但通过电脑的ip地址就连接失败,在网上查询了下,好像是因为忘记给数据库授权。解决方案如下:
在终端用root账户登录mysql;
C:\Users\you>mysql -uroot -p Enter password: ****** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 193231 Server version: 5.7.17-log MySQL Community Server (GPL) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
输入命令:grant all privileges on *.* to '用户名'@'IP地址' identified by '密码';
用户名,随便起
IP,数据库所在的IP地址
identified by ‘密码’ 表示通过密码连接
mysql> grant all privileges on *.* to 'root'@'192.168.1.97' identified by '123456'; Query OK, 0 rows affected, 1 warning (0.01 sec)
执行完上述命令后用下面的命令刷新一下权限
flush privileges;
mysql> flush privileges; Query OK, 0 rows affected (0.02 sec)
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦