Home > Database > Mysql Tutorial > mysql 用localhost能连用IP不能连_MySQL

mysql 用localhost能连用IP不能连_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 13:44:22
Original
1166 people have browsed it

bitsCN.com

 

今天犯了一个非常低级的错误:MySQL 可以用localhost 连接,但不能用IP连接

 

 

 

结果原因是忘记了给数据库授权。用grant命令在MySQL的命令行控制台中处理一下就可以了。

 

 

 

grant all privileges on *.* to '用户名'@'IP地址' identified by '密码';

 

all privileges 所有权限 也可以写成select ,update等

*.* 所有库的所有表 如databasename.*

用户名 随便起

IP  数据库所在的IP

identified by ‘密码’ 表示通过密码连接

 

 

 

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

 

flush privileges;

 

作者cooler1217

bitsCN.com
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template