亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

MySQL 可以用localhost 連接,但不能用IP連接

標簽:
MySQL

重新安装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 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
Python工程師
手記
粉絲
11
獲贊與收藏
54

關注作者,訂閱最新文章

閱讀免費教程

  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消